Note that there are some explanatory texts on larger screens.

plurals
  1. POgetView method is never called in Baseadapter
    text
    copied!<p>I have a <code>ListView</code> and populating it using a <code>BaseAdapter</code>.</p> <p>Although <code>getCount()</code> method return 4, But the <code>getView</code> method is not called because <code>Log.i("Inside Get View"," ");</code> is not appears in Logs:</p> <p>Here I am trying to show all the <code>SMS(Inbox)</code> in <code>ListView</code></p> <pre><code> public class AllSMSListAdapter extends BaseAdapter { private Context mContext; ArrayList&lt;String&gt; SMSContactList; Cursor cursor; public AllSMSListAdapter(Context context,Cursor cur) { super(); SMSContactList=new ArrayList&lt;String&gt;(); mContext=context; cursor=cur; } public int getCount() { { Log.i("Number of Records returned:"+cursor.getCount()," In get count "); return cursor.getCount(); } } public View getView(int position, View view, ViewGroup parent) { Log.i("Inside Get View"," "); if (view == null) { LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.each_sms, null); } cursor.moveToPosition(position); String senderNumber=cursor.getString(cursor.getColumnIndex("address")); String smsBody=cursor.getString(cursor.getColumnIndex("body")); SMSContactList.add(senderNumber); TextView textViewConatctNumber = (TextView)view.findViewById(R.id.textViewSMSSenderAll); TextView textViewSMSBody=(TextView)view.findViewById(R.id.textViewSMSBodyAll); Log.i(senderNumber," "+smsBody); textViewConatctNumber.setText(senderNumber); textViewSMSBody.setText(smsBody); return view; } public Object getItem(int position) { // TODO Auto-generated method stub return position; } public long getItemId(int position) { // TODO Auto-generated method stub return position; } } </code></pre> <p>ListView XML :</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" android:orientation="vertical" &gt; &lt;ListView android:id="@+id/listAllSMSes" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent" android:dividerHeight="0.1dp" android:divider="#000000" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>Each Row of ListView:</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" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/textViewSMSSenderAll" android:layout_height="wrap_content" android:layout_width="fill_parent" android:textColor="#CC0000" android:text="Sender Number" android:layout_marginLeft="5dp" android:textSize="20dp"/&gt; &lt;TextView android:id="@+id/textViewSMSBodyAll" android:textColor="#006600" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Message" android:layout_marginLeft="1dp" android:layout_marginBottom="7dp" android:textSize="17dp"/&gt; &lt;/LinearLayout&gt; </code></pre>
 

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