i am new in android environment. I am trying to develop an app which retrieve data from data base fetching and all other ok but i want to pass edit and delete button to each listed informaton i have no idea how to pass create and pass button to each listed row.
Asked
Active
Viewed 1,892 times
1
-
Stack Overflow is a place to get help with a problem with code you've written. Requests such as yours generally don't get much positive response. Start writing code to do this and when you run into a problem, post a question with the code that isn't working and someone will be glad to help you! – Tony Hinkle May 29 '15 at 14:48
-
follow this [link][1] on stackoverflow [1]: http://stackoverflow.com/questions/17525886/listview-with-add-and-delete-buttons-in-each-row-in-android – Durga Mohan May 29 '15 at 14:53
-
thank you for your response. Link is very useful. thanks.. Dear here i face an other problem. actually list is populated on the bases of database. so i need to assign database id to to each list item of Custom listView So kindly help me how to assign id to list item for deletion of item from both item list and database at a time on the basis of those id i have very thankful to you for that... – user3032316 May 29 '15 at 18:56
-
You can add one for to your list model or the map using to populate the listview. – Sanjeet A May 30 '15 at 05:34
1 Answers
1
In your MyRecyclerviewAdapter,add your buttons in the on Bind method
public class ViewHolder extends RecyclerView.ViewHolder {
TextView trans;
TextView from;
TextView to;
TextView est_dest;
public ViewHolder(View itemView) {
super(itemView);
trans=(TextView)itemView.findViewById(R.id.trans);
from=(TextView)itemView.findViewById(R.id.from);
to=(TextView)itemView.findViewById(R.id.to);
est_dest=(TextView)itemView.findViewById(R.id.est_distance);
}
}
//If you are using a listview,you can add the button in your adapter
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
//view you wat to show in the list item
convertView = View.inflate(ListCred.this, R.layout.cred_item_layout, null);
return convertView;
}
private class ViewHolder {
public ImageView imageView;
public TextView name;
public TextView pos;
private ViewHolder(View v) {
//instantiate your buttons
imageView = (ImageView) v.findViewById(R.id.imageView);
name = (TextView) v.findViewById(R.id.name);
pos = (TextView) v.findViewById(R.id.pos);
}
}

Mushirih
- 451
- 5
- 13