Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom List view with button : make visible on some condition
    primarykey
    data
    text
    <p>I am getting data from json parsing from URl and depending on some data from json I need to make the customized list-view button visible otherwise its in invisible state. If condition is like <code>String == "123"</code> then I need to set the button visible. the below code set the button to visible but when i scroll back, it will appear in some other rows as well. Its is not appearing correctly. The button should appear only in row which satisfy the condition. How can solve this?.</p> <p>In my layout I set the button like below:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/list_selector" android:orientation="horizontal" android:padding="5dip" &gt; &lt;!-- ListRow Left side Thumbnail image --&gt; &lt;LinearLayout android:id="@+id/thumbnail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip" android:layout_alignParentLeft="true" android:background="@drawable/image_bg" android:layout_marginRight="5dip"&gt; &lt;ImageView android:id="@+id/list_image" android:layout_width="70dip" android:layout_height="70dip" android:src="@drawable/ic_launcher"/&gt; &lt;/LinearLayout&gt; &lt;!-- Title Of program--&gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/thumbnail" android:layout_toRightOf="@+id/thumbnail" android:text="title Name" android:textColor="#040404" android:typeface="sans" android:textSize="15dip" android:textStyle="bold"/&gt; &lt;!-- category Name --&gt; &lt;TextView android:id="@+id/subtitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/title" android:textColor="#343434" android:textSize="10dip" android:layout_marginTop="1dip" android:layout_toRightOf="@+id/thumbnail" android:text="subtitle" /&gt; &lt;!-- start time --&gt; &lt;TextView android:id="@+id/time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/subtitle" android:layout_toRightOf="@+id/thumbnail" android:text="time" android:layout_marginRight="5dip" android:textSize="10dip" android:textColor="#10bcc9" android:textStyle="bold"/&gt; &lt;!-- Rightend button --&gt; &lt;Button android:id="@+id/watch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/watchnow" android:layout_alignParentRight="true" android:layout_below="@+id/time" android:layout_centerVertical="true" android:clickable="true" android:focusable="false"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And my getView code is like below:</p> <pre><code> public View getView(int position, View convertView, ViewGroup parent) { View vi=convertView; if(convertView==null) vi = inflater.inflate(R.layout.single_row, null); final TextView title = (TextView)vi.findViewById(R.id.title); // title TextView artist = (TextView)vi.findViewById(R.id.subtitle); // artist name TextView duration = (TextView)vi.findViewById(R.id.time); // duration ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image HashMap&lt;String, String&gt; song = new HashMap&lt;String, String&gt;(); song = data.get(position); title.setText(song.get(CustomizedListView.TAG_NAME)); artist.setText(song.get(CustomizedListView.TAG_PR)); duration.setText(song.get(CustomizedListView.TAG_DES)); imageLoader.DisplayImage(song.get(CustomizedListView.TAG_PID), thumb_image); if(duration.getText().toString().equalsIgnoreCase("123456")){ Button watch = (Button)vi.findViewById(R.id.watch); watch.setVisibility(View.VISIBLE); } return vi; } </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.
 

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