現在ListViewをカスタムAdapterを使用して作ろうと思っているのですが、Adapter側のクラスのgetViewのメソッドが呼ばれません。
lang
1class MyAdapter extends ArrayAdapter<MyItem> { 2 private LayoutInflater inflater; 3 4 public MyAdapter(Context context, int resource, ArrayList<MyItem> arr) { 5 super(context, resource, arr); 6 inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 7 // ここは呼ばれる 8 Log.v("コンストラクタ","アダプターのコンストラクタが呼ばれました"); 9 } 10 11 @Override 12 public View getView(int position, View convertView, ViewGroup parent) { 13 // ここから呼ばれない 14 Log.v("getView","getViewが呼ばれました"); 15 if (convertView == null) { 16 convertView = inflater.inflate(R.layout.item_row, null); 17 } 18 MyItemitem = getItem(position); 19 TextView listtext = (TextView) convertView.findViewById(R.id.listtext); 20 name.setText(item.getName()); 21 return convertView; 22 } 23}
アダプターはこんな感じに作っています。
ListViewの方は
lang
1ArrayList<MyItem> arr = new ArrayList<>(); 2//arrにアイテムを入れる操作 3for~~~~~~~~ 4 5listView.setAdapter( 6getApplicationContext(), 70, 8arr 9);
リストへのセットはこんな感じです。
完全に詰まっているのでどうかご教授願いますm(_ _)m
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。