last day (15 days later) » 

3:47 PM
1
Q: How can i use Button OnClick in Custom ListView with View Holder

de_la_vega_66I need some help, i am using a viewholder to display from a dynamic arrayadapter. I have list view . Each row contains ; Title (Textview), sub title(TextView), Progress bar Download Button (Button). I want to show progress bar and hide Download Button when Download Button is clicked. When...

 
put vi.setTag(viewHolder); in if (vi == null) block
 
it's almost below viewHolder.DownloadButton.setOnClickListener
 
then why it is again after else?? remove it
 
i removed and updated code but the result is same. when i clicked first button it's showing first progress bar, 8th progress bar,16th progress var etc. :(
 
what is refreshDrawableState ??
 
3:47 PM
it's refresing the listview row. if i don't write it it's not showing progress bar.
 
show me its code
 
i tried your code but result is same
 
show me refreshDrawableState's code
 
it's View.class's method.
when i ctrl+clicked on it its opening the View.Class
 
Ohk
ur code seems fine..
 
3:52 PM
:/
so what's my problem?
 
do u require two show progress bar in two list item at a time ??
mean simultaneous download ??
 
if the user wants it can download simultaneous.
this is my Xml. is there any mistake?
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/AliceBlue"
android:orientation="vertical" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
android:id="@+id/RowTitle"
 
i can't find any
 
i dont know what must i do.
 
will let you if i find any solution
 
4:00 PM
thank U.
 
remove Click from if block as @waqaslam said
 
i tried it before
 
i saw it's not working.
then i remove it into the if/else block
 
ya put if after else only
 
4:10 PM
this is my last code
public View getView(final int position, View vi, ViewGroup parent) {
ViewHolder viewHolder;
if (vi == null) {
vi = inflater.inflate(R.layout.tab_incoming_row, parent, false);
viewHolder = new ViewHolder();
viewHolder.title = (TextView) vi.findViewById(R.id.RowTitle);
viewHolder.desc = (TextView) vi.findViewById(R.id.RowDesc);
viewHolder.DownloadButton = (Button) vi
.findViewById(R.id.RowDownloadButton);
viewHolder.pB = (ProgressBar) vi
.findViewById(R.id.RowDownloadProgress);
vi.setTag(viewHolder);
 
still facing the same?
 
yes :(
 
it's without ViewHolder. i tried this too. then i got this error :
button is hiding, progress bar is showing
but if you scroll down and scroll up
button is showing, progress bar is hiding
 
You need to remember the state of button for which the download is called upon.
reset the states of your views to default before setting new values/listeners and then check if the view on given item position needs to be shown or hidden based on the previous action.
This logic is critical in adapters as it performs recycling on its view items.
 
4:27 PM
i saw people who can do this. but i can't. i am very angry to myself.
Thank you for your help.
i think, i will delete all of my code and i will write again.
 

last day (15 days later) »