Sunday, November 27, 2011

Re: [android-developers] LIstView not working

Change this line in the adapter.

Replace your code Adapet line with the below one.
  

lv1.setAdapter(new ArrayAdapter<String>( android.R.layout.simple_list_item_1 , lv_arr));


Warm Regards,
Mukesh Kumar,
Android Consultant/Freelancer,
India,Hyderabad.



On Mon, Nov 28, 2011 at 9:53 AM, Kiran Kumar Kendole <k.kirankumar1582@gmail.com> wrote:
Hi Guys..
this is my code... I want to show a set of strings as List. But its not working for me.. and showing exceptions.. can anybody help me.

JAVA file:

package com.ta.coe;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class DataListView extends ListActivity{
private ListView lv1;
private String lv_arr[]= new String[]{"Android","iPhone","BlackBerry","AndroidPeople"};
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.data_list_view);
lv1=(ListView)findViewById(R.id.list);
// By using setAdpater method in listview we an add string array in list.
lv1.setAdapter(new ArrayAdapter<String>(this,R.id.list , lv_arr));
}
}
=================================
XML File:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
    <ListView
android:id="@+id/list"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
/>
</LinearLayout> 

Please send me the correct code..

Thanks
KIRANKUMARKENDOLE

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment