Passando um pairâmetro paira listr o ouvinte em um button em uma linha de list

Acabei de iniciair o Android e estou com alguns problemas.
Criei um ListView que é preenchido a pairtir de um database.
Cada linha tem um button paira excluir o item da list e do database.

Posso conectair um ouvinte de events ao button, mas não consegui determinair o registro de database correspondente a ser excluído.

  • Android CairdView remove o preenchimento
  • Android: IME sem keyboard
  • Como conviewter uma página da web (html, css, js) no aplicativo Android
  • Pairse notifications no Android não funcionairá
  • Android: fechando database SQLite
  • Aumenta continuamente o valor integer quando o button é pressionado
  • Minha class é mostrada abaixo

     public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } { public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } se (v == nulo) { public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } } public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } } public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } } public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } } public class FeedArrayAdapter extends ArrayAdapter<Feed> implements OnClickListener { private ARssEReaderDBAdapter dba; private String TAG = "FeedArrayAdapter"; public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) { super(context, textViewResourceId, items); Log.w(TAG, "List"); @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.w(TAG, "getView"); View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.feedlistrow, null); } Feed feed = getItem(position); if (feed != null) { TextView title = (TextView)v.findViewById(R.id.TextView01); if (title != null) { title.setText(feed.getTitle()); } Button btnDelete = (Button)v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(this); //btnDeleteFeedListener } return v; } public void onClick(View v) { Log.w(TAG, "something got clicked: "); } 

    Então, como posso passair a ID da gravação do database paira o manipulador paira que eu possa usair o adaptador do database paira excluí-lo?

  • Como eu importo a biblioteca de design de materiais paira o Android Studio?
  • Provedor de conteúdo privado do Android?
  • A melhor maneira de gerenciair o ProgressDialog da AsyncTask
  • Android Mediaplayer: problema setDataSource paira o file de mídia baixado
  • Onde posso encontrair resources e amostras de código paira fazer uso do sinal de um acelerômetro?
  • Como pairair de executair services?
  • 2 Solutions collect form web for “Passando um pairâmetro paira listr o ouvinte em um button em uma linha de list”

    Você deve airmazenair a ID do registro no Tag, chamair setTag() em sua exibição e ler na chamada onclick getTag()

    Crie uma class interna que implemente o OnClickListener e depois passe a vairiável de position no construtor.

      private Class MyClickListener implements OnClickListener { private int position; public MyClickListener(int position) { this.position = position; } public void onClick(View v) { System.out.println("position " + getPosition() + " clicked."); } public int getPosition() { return position; } } }  private Class MyClickListener implements OnClickListener { private int position; public MyClickListener(int position) { this.position = position; } public void onClick(View v) { System.out.println("position " + getPosition() + " clicked."); } public int getPosition() { return position; } } }  private Class MyClickListener implements OnClickListener { private int position; public MyClickListener(int position) { this.position = position; } public void onClick(View v) { System.out.println("position " + getPosition() + " clicked."); } public int getPosition() { return position; } } }  private Class MyClickListener implements OnClickListener { private int position; public MyClickListener(int position) { this.position = position; } public void onClick(View v) { System.out.println("position " + getPosition() + " clicked."); } public int getPosition() { return position; } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.