我試圖檢索列表中的項目時點擊一個確定的ID。從Android中的多個ID列表項獲取ID值
如何檢索值+標識/名稱?我想在下面顯示的警告對話框中使用它。
我目前用一個簡單的烤麪包這只是顯示在目前「名稱」時,點擊
下面列表項工作是我的列表項的XML代碼:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/image" android:textSize="20dip"
android:layout_marginLeft="10dip"/>
<ImageView
android:id="@+id/image"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_centerHorizontal="true"
android:src="@drawable/stub" android:scaleType="centerCrop"/>
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/image"
android:textSize="20dip" android:layout_marginLeft="10dip"/>
</RelativeLayout>
警報對話框代碼:
list.setOnItemClickListener(新OnItemClickListener(){
String artistname = "get +id/name here";
String items[] = {"Youtube", "Soundcloud"};
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
AlertDialog.Builder builder = new
AlertDialog.Builder(JsonActivity.this);
builder.setTitle(artistname);
builder.setItems(items, new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog alert = builder.create();
alert.show();
}});
}
你的問題是....? – Pragnani 2013-02-20 10:21:17
我不明白你的問題,請詳細說明 – Shoshi 2013-02-20 10:26:51
@Pragnani如何檢索值+標識/名稱?我想在上面顯示的警告對話灰中使用它。 – AndroidEnthusiast 2013-02-20 10:26:52