每当我点击之前在 OSM 地图上设置的特定 POI 时,我想弹出一个包含详细信息的对话框(例如:经度、纬度、描述和从 SQLite Db 提取的缩略图)。如果有人可以帮助我,我将不胜感激...
1 回答
-1
这是一个示例,说明如何为缩略图创建带有 textviews 和 imageview 的自定义对话框
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/geo_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/player_name"
android:layout_below="@id/geo_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
然后扩展对话框
private Dialog constructYourDialog(){
//Preparing views
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.***your_xml_name***, (ViewGroup) findViewById(R.id.***Yout view id***));
//Building dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setNeutralButton("Show me more", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
return alert;
}
于 2012-01-16T18:23:08.093 回答