Note that there are some explanatory texts on larger screens.

plurals
  1. POListView row height and another interesting issue of selective focus (when the parent is scrolled)
    primarykey
    data
    text
    <p>First of all, excuse me if it sounds duplicate. I have visited so many threads but couldn't find a suitable answer of my problem. I have tried ScrollingMovementMethod, android:scrollbar, wrap_content in the parent and many other things suggested in those threads but nothing worked for me. Feel free to edit the title as I couldn't find a better one.</p> <p><strong>Problem Description</strong> I have a list view and each row of the listview has three controls 1. Image View (to Show the contact image) 2. TextView (to show the Contact name) 3. TextView (to show the status message of the contact (if available)).</p> <p><strong>What I have tried</strong>:- 1. XML layout ,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ImageView android:id="@+id/icon" android:layout_width="22dp" android:layout_height="50dp" android:layout_marginLeft="4dp" android:layout_marginRight="15dp" android:contentDescription="@string/strBuddyImage" &gt; &lt;/ImageView&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:minHeight="56dp" &gt; &lt;TextView android:id="@+id/uNameTxt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/customMsg" android:minHeight="?android:attr/listPreferredItemHeight" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceMedium" android:textSize="@dimen/fontSizeListRowHeader" /&gt; &lt;TextView android:id="@+id/customMsg" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:maxLines="4" android:textSize="@dimen/fontSizeListRowText" android:textStyle="italic" /&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <ol start="2"> <li><p>Adapter Which extends ArrayAdapter (which only overrides the getView method)</p> <p>static class ViewHolder { public ImageView imageView; public TextView uNameTxtView; public TextView custMsgTxtView; }</p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; // Log.d("BuddyListAdapter", "Inside getView() " + position); if ( rowView == null ) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.buddy_listview_row_layout, parent, false); viewHolder = new ViewHolder(); viewHolder.uNameTxtView = (TextView) rowView.findViewById(R.id.uNameTxt); viewHolder.imageView = (ImageView) rowView.findViewById(R.id.icon); viewHolder.custMsgTxtView = (TextView) rowView.findViewById(R.id.customMsg); rowView.setTag(viewHolder); } viewHolder = (ViewHolder) rowView.getTag(); synchronized (buddyList) { buddy = buddyList.get(position); } viewHolder.uNameTxtView.setText(buddy.getDisplayName()); viewHolder.custMsgTxtView.setText(buddy.getCustomMessage()); // Change the icon for users who are offline if ( buddy.getState() == 0 ) { viewHolder.imageView.setImageResource(R.drawable.offline); } else { viewHolder.imageView.setImageResource(R.drawable.online); } // rowView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); return rowView; } </code></pre></li> </ol> <p><strong>What I get</strong> <img src="https://i.stack.imgur.com/F5Rz7.png" alt="enter image description here"></p> <p><strong>Desired</strong> I want to show all the rows of list view of same size and if someone has a bigger Status message (Which needs multiple lines) I would like to show the name of the person and first few lines (say 4) of the status message. No matter how big the status message is name should be always visible to the user.. How can I do that ?</p> <p>Please point if any other mistake you find in the code. </p>
    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.
    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