私は、他のアクティビティを通じて項目を追加したリストビューを持っています。ここでの私の目標は、それがアイテムに固有のクリックダイアログボックスを起動し、特定のListView項目がをクリックされたとき、それは、どこにすることです。ここで特定のListViewアイテムをクリックしてダイアログボックスを作成する方法は?
は、リストビュー
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ListView
android:id="@+id/inventoryListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
android:headerDividersEnabled="true"
android:onClick="f">
</ListView>
</LinearLayout>
</LinearLayout>]
そして、ここでは、アダプタ
public class inventory extends AppCompatActivity {
public static ArrayList<String> items;
public static ArrayAdapter<String> adapter;
public static ListView inventoryListView;
SharedPreferences sharedPreferences;
protected void onCreate(Bundle savedInstanceSate){
super.onCreate(savedInstanceSate);
setContentView(R.layout.inventory);
inventoryListView = (ListView)findViewById(R.id.inventoryListView);
items = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this,R.layout.inventory_list_view,items);
inventoryListView.setAdapter(adapter);
sharedPreferences = getSharedPreferences("my_prefs", 0);
updateInventory();
adapter.notifyDataSetChanged();
}
リストとの活動が保持している1、それが唯一の他の活動を通じて取り込むことができるので、人口ではなく、ではないのですリストビュー。
例や擬似コードを取得できますか? –