Note that there are some explanatory texts on larger screens.

plurals
  1. POListview problem
    text
    copied!<p>Actually i have created an customListview,here i want to add item dynamically..but in my case the first item inserted with any problem but when i try to insert the second item..its give an error i will send the code..if anyone know please suggest it..</p> <p>code for main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;ListView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/historyFrmLstView2" android:layout_alignParentLeft="true" android:layout_below="@+id/historyFrmLstView1" android:layout_marginTop="20dip" android:layout_marginBottom="10dip"&gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>code for ListView.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:padding="5dip" android:background="#00000000"&gt; &lt;TextView android:textSize="18dp" android:layout_height="wrap_content" android:textColor="#000000" android:background="@drawable/history_scroll_title_label_bg" android:layout_width="wrap_content" android:id="@+id/txtHistoryDisplay" android:layout_below="@+id/txtViewHeading" android:layout_marginTop="0dip" android:layout_marginLeft="2dip"&gt; &lt;/TextView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>code for main.java</p> <pre><code> public void displayHistory() { String strDisplay[] = {" "}; historyFrmLstView2 = (ListView) findViewById(R.id.historyFrmLstView2); int iHistCount = CycleManager.getSingletonObject().getHistoryCount(); int i; SimpleDateFormat sdFormatter = new SimpleDateFormat("dd-MMMM-yyyy"); for (i=0; i&lt;iHistCount; i++) { strDisplay[i] = ""; Date dtHist = CycleManager.getSingletonObject().getHistoryDate(iHistCount); strDisplay[i]=sdFormatter.format(dtHist.getTime()); aHistFrmAdpter2 = new HistoryFrmCustomAdapter2(this,strDisplay); historyFrmLstView2.setAdapter(aHistFrmAdpter2); } } </code></pre> <p>code for custom Adapter.java</p> <pre><code>public class HistoryFrmCustomAdapter2 extends BaseAdapter { public String heading1[]; public Activity context; public LayoutInflater inflater; public HistoryFrmCustomAdapter2(Activity context,String[] heading1) { super(); this.context = context; this.heading1=heading1; this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { return heading1.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } public static class ViewHolder { TextView txtHistoryDisplay; } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView==null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.histryfrm_listview2, null); holder.txtHistoryDisplay =(TextView) convertView.findViewById(R.id.txtHistoryDisplay); convertView.setTag(holder); } else holder=(ViewHolder)convertView.getTag(); holder.txtHistoryDisplay.setText(heading1[position]); return convertView; } } </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