2

IDから識別するバーコードスキャナーからデータを取得し、Webサービスを介してデータベースから詳細を表示するアプリケーションを作成しています。現在、テキストビューとボタンを持つカスタムリストを使用していますが、テキストビューに埋め込みたいデータは正しく表示されています...

私の質問は、ボタンクリックでリストから特定の行を削除する方法です。

これがカスタム アダプター コードです。

 public class MyCustomAdapter extends ArrayAdapter<String> 
     {
         public MyCustomAdapter(Context context, int textViewResourceId, ArrayList<String> items) 
         {
             super(context, textViewResourceId, items);
         }

         @Override
         public View getView(int position, View convertView, ViewGroup parent)
         {

             LayoutInflater inflater = FusionMain.this.getLayoutInflater();
             View row = inflater.inflate(R.layout.list_row, parent, false);


             return row;
         }
     } // end MyCustomAdapter

カスタムアダプターで他にどのような関数を作成する必要がありますか? 私はアンドロイド開発の初心者です。さらに詳細が必要な場合は、質問またはコードを更新できます。親切に対応

4

4 に答える 4

0

Simple must need to remove item from list and call function notifyDataSetChanged

 ImageButton dltbutton = (ImageButton) row.findViewById(R.id.removebtn);
        dltbutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                myModel.remove(position);
                notifyDataSetChanged();
            }
        });

Check my answer below:-

https://stackoverflow.com/a/39243875/1733810

于 2016-08-31T10:01:46.727 に答える