Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Adding a button to each row in the listview
    primarykey
    data
    text
    <p>For some reason I am unable to view the button that I have included in the row.xml file for the list view.</p> <p>This is the main.xml that I am using</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ListView android:id="@+id/friendsListView" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>row.xml is the following</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="2dp"&gt; &lt;ImageView android:id="@+id/imgIcon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_marginRight="10dp" android:contentDescription="@string/fbUserPic"/&gt; &lt;TextView android:id="@+id/txtTitle" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:textStyle="normal" android:textSize="12dp" android:textColor="#FFFFFF"/&gt; &lt;Button android:id="@+id/btnPost" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/fbbtnPost" android:focusable="false"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>The following is the getView override in the custom adapter that I am using</p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; FriendRowHolder friendHolder = null; if (row == null) { LayoutInflater inflater = ((Activity)objContext).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); friendHolder = new FriendRowHolder(); friendHolder.txtTitle = (TextView) row.findViewById(R.id.txtTitle); friendHolder.imgIcon = (ImageView) row.findViewById(R.id.imgIcon); friendHolder.btnPost = (Button) row.findViewById(R.id.btnPost); row.setTag(friendHolder); } else { friendHolder = (FriendRowHolder)row.getTag(); } Friend objFriend = lstFriends.get(position); friendHolder.txtTitle.setText(objFriend.GetName()); friendHolder.imgIcon.setImageBitmap(loadBitmap(objFriend.GetPictureURL())); friendHolder.btnPost.setText("Hi"); return row; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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