문제

I have been working on a certain project which involves the use of web service. I have a list of products that will display in UI as Image,Button to Like,Add To List and some other. I have implemented these items in a Custom ListView and added the products in the Adapter class as always. If I select a Like button for a certain image then the button should change to Unlike, the problem that I am facing here is that the button changes for all the items i.e. all the buttons in the list view gets changed to Like which is idiotic.

Question :

How do I pinpoint a certain list item to get changed (or) How do I change a single button in a list ?

I am short of logic to be used here. Any help will be much appreciated.

올바른 솔루션이 없습니다

다른 팁

Without code it is difficult to help specifically, but have you tried using something like,

listview.getChildAt(position);

to reference a particular list item.

Depending on your code, you can modify this:

yourlistview.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                    long arg3) {

                //on click of any item.
                Toast.makeText(getApplicationContext(), "Your position"+position, Toast.LENGTH_LONG).show();

                //This is just for example to obtain the position of the listview item.
                TextView example= (TextView)findViewById(R.id.sometext);
                example.setText(String.valueOf(position));

            }
        });

Hope this gives you some information..:)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top