Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the parent view of a button within a list adapter?
    primarykey
    data
    text
    <p>i`m from brazil and I have a listview that contains buttons images and texts. I'm trying to click on the button listview and get the view responsible for the line I'm clicking. so I can make changes on the line where this my button.</p> <p>what is happening and if the code below, when I click the button, whichever button the list he always does the change in the first list item, and I wanted him to do in their respective line. thus this list</p> <p>IMAGE ------------ --------------- TEXT -- BUTTON<br> IMAGE ------------ --------------- TEXT -- BUTTON<br> IMAGE ------------ --------------- TEXT -- BUTTON<br> IMAGE ------------ --------------- TEXT -- BUTTON<br></p> <p>I click on the button and he just change the text of his line example:<br></p> <p>IMAGE ------------ --------------- TEXT -- BUTTON <br> IMAGE ------------ --------------CHANGE -- BUTTON &lt;--CLICKED<br> IMAGE ------------ --------------- TEXT -- BUTTON <br> IMAGE ------------ --------------- TEXT -- BUTTON <br></p> <p>AND..</p> <p>IMAGE ------------ --------------- TEXT -- BUTTON <br> IMAGE ------------ --------------- TEXT -- BUTTON <br> IMAGE ------------ --------------- TEXT -- BUTTON <br> IMAGE ------------ --------------CHANGE -- BUTTON &lt;--CLICKED<br></p> <p>Recalling that and used an adapter inside the fragment list Sorry , my english is bad!</p> <pre><code>public class JAdapterList extends BaseAdapter implements OnClickListener { private LayoutInflater mInflater; private ArrayList&lt;JItemList&gt; itens; public JAdapterList(Context context, ArrayList&lt;JItemList&gt; itens) { //Itens que preencheram o listview this.itens = itens; //responsavel por pegar o Layout do item. mInflater = LayoutInflater.from(context); } public int getCount() { return itens.size(); } public JItemList getItem(int position) { return itens.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View view, ViewGroup parent) { //Pega o item de acordo com a posção. JItemList item = itens.get(position); //infla o layout para podermos preencher os dados view = mInflater.inflate(R.layout.navlistitem, null); ((TextView) view.findViewById(R.id.textListView)).setText(item.getNome()); ImageButton ib = (ImageButton) view.findViewById(R.id.imageButton1); ib.setOnClickListener(this); return view; } @Override public void onClick(View v) { // TODO Auto-generated method stub View vv = v.getRootView(); ImageView tv = (ImageView) vv.findViewById(R.id.imageView1); TextView texto = (TextView) vv.findViewById(R.id.textListView4); texto.setText("CHANGE"); tv.setAnimation(AnimationUtils.loadAnimation(tv.getContext(), R.anim.motion)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload