So I'm getting 3 errors "final int sortColumnIndex = c.getColumnIndex(YOUR_SORT_COLUMN_NAME);" & "public class MyAdapter extends CursorAdapter implements SectionIndexer" <---this one is getting marked as an error twice.
My MainActivityNext.java
package testing.android.application.three;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import android.os.Bundle;
import android.support.v4.widget.CursorAdapter;
import android.widget.AlphabetIndexer;
import android.widget.ArrayAdapter;
import android.widget.SectionIndexer;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
public class MainActivityNext extends ListActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_next);
}
public class MyAdapter extends CursorAdapter implements SectionIndexer
{
// All valid characters. May want to include numbers, etc if they show up
// in your sort column
private final static String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
private AlphabetIndexer mIndexer = null;
public MyAdapter(Context context, Cursor c, int flags)
{
super(context, c, flags);
// Assumes your cursor is non-null,
// otherwise do this in swapCursor if mIndexer==null
final int sortColumnIndex = c.getColumnIndex(YOUR_SORT_COLUMN_NAME);
mIndexer = new AlphabetIndexer(c, sortColumnIndex,
ALPHABET);
}
public Cursor swapCursor(Cursor newCursor)
{
super.swapCursor(newCursor);
// Make sure the AlphabetIndexer knows about the new Cursor
mIndexer.setCursor(newCursor);
return newCursor;
}
public int getPositionForSection(int section)
{
// AlphabetIndexer does all the hard work
return mIndexer.getPositionForSection(section);
}
public int getSectionForPosition(int position)
{
// AlphabetIndexer does all the hard work
return mIndexer.getSectionForPosition(position);
}
public Object[] getSections()
{
// AlphabetIndexer does all the hard work
return mIndexer.getSections();
}
}
}
According to your Logcat:
Unable to start activity ComponentInfo{testing.android.application.three/testing.android.application.three.MainActivityNext}:
java.lang.RuntimeException: Your content must have a ListView whose id
attribute is 'android.R.id.list'
Whenever you use or extend a listactivity the view you build for it must have a listview with that id.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FF00"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<TextView android:id="#android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:text="No data"/>
</LinearLayout>
See http://developer.android.com/reference/android/app/ListActivity.html for more info on it.
as in log:
our content must have a ListView whose id attribute is
'android.R.id.list'
means you will need to use #id/android:list id in xml for ListView. do it as:
<ListView android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
..../>
If your activity extends the ListActivity then you have to set the id of the xml of your ListView like below
< ListView
android:id="#android:id/list"
...
Related
I have a simple searchable listview with checkboxes but it can't remember my selections when it's getting filtered.
when I filter a value and mark related checkbox then my choice won't be kept after clearing search value ...
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:id="#+id/btnChecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:foregroundGravity="center_horizontal"
android:text="Get checked items"></Button>
<EditText
android:id="#+id/searchFilter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Search Ingredients"
android:textColor="#color/material_on_surface_emphasis_medium" />
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
MainActivity.java
package com.example.listview;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Filter;
import android.widget.ListView;
public class MainActivity extends Activity implements OnClickListener {
final String LOG_TAG = "myLogs";
ListView lvMain;
String[] names;
private ArrayAdapter<CharSequence> adapter;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText theFilter = (EditText) findViewById(R.id.searchFilter);
lvMain = (ListView) findViewById(R.id.lvMain);
// here we adjust list elements choice mode
lvMain.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
// create adapter using array from resources file
adapter = ArrayAdapter.createFromResource(
this, R.array.names,
android.R.layout.simple_list_item_multiple_choice);
lvMain.setAdapter(adapter);
Button btnChecked = (Button) findViewById(R.id.btnChecked);
btnChecked.setOnClickListener(this);
// get array from resources file
names = getResources().getStringArray(R.array.names);
theFilter.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
(MainActivity.this).adapter.getFilter().filter(charSequence);
SparseBooleanArray scArray = lvMain.getCheckedItemPositions();
}
#Override
public void afterTextChanged(Editable editable) {
// Uncheck everything:
for (int i = 0; i < lvMain.getCount(); i++) {
if (lvMain.isItemChecked(i)) {
lvMain.setItemChecked(i, true);
} else {
lvMain.setItemChecked(i, false);
}
}
}
});
}
public void onClick(View arg0) {
Log.d(LOG_TAG, "checked: ");
SparseBooleanArray sbArray = lvMain.getCheckedItemPositions();
for (int i = 0; i < sbArray.size(); i++) {
int key = sbArray.keyAt(i);
if (sbArray.get(key))
Log.d(LOG_TAG, names[key]);
}
}
}
as you can see in below pictures, it can't remember "Petr" and "Ivan" selected wrongly after search ...
It is because ArrayAdapter does not support this. You need to create a custom adapter that will remember what has been checked so that when it redraws a view it does not take the default value of unchecked.
Create a class that extends from BaseAdapter that works on an ArrayList<Model> instead of string array. In this Model you can have a boolean checked (initially all false). That way when user scrolls around or searches your model will know weather current name is selected.
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 4 years ago.
I am new to Java and Android When Ever I tried to connect my android app to SQLite it generates a null point error, every time it crashes app on calling the onCreate method on Database helper class.
I am unable to find the error in my code so please someone help me.
MainActivity.java Code:
package com.example.sdreddy.dbfinal;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
DbNeed dbn;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button dd=(Button)findViewById(R.id.button);
dd.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
TextView tv = (TextView) findViewById(R.id.textView);
try {
dbn.Addd("SDREDDY");
String zz = dbn.getdata();
tv.setText(zz);
}
catch (Exception ee){
tv.setText((CharSequence) ee.toString());
}
}
});
}
}
DbNeed.java Code
package com.example.sdreddy.dbfinal;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
/**
* Created by SDREDDY on 26-04-2018.
*/
public class DbNeed extends SQLiteOpenHelper {
public static final String dbname="Database.db";
public static final String tblname="MyTable";
public DbNeed(Context context) {
super(context, dbname, null, 1);
}
#Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("create table if not exists "+tblname+" (id text,value text)");
}
#Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL("drop table if exists "+tblname);
onCreate(sqLiteDatabase);
}
public void Addd(String Name){
SQLiteDatabase sqLiteDatabase=this.getWritableDatabase();
ContentValues cv=new ContentValues();
Random r=new Random();
String idz=String.valueOf(r.nextInt());
cv.put("id",idz);
cv.put("name",Name);
sqLiteDatabase.insert(tblname,null,cv);
sqLiteDatabase.close();
}
public String getdata(){
SQLiteDatabase sqLiteDatabase=this.getReadableDatabase();
String qu="SELECT * FROM "+tblname;
Cursor crz=sqLiteDatabase.rawQuery(qu,null);
sqLiteDatabase.close();
String sim=crz.getString(0);
return sim;
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sdreddy.dbfinal.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="30sp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Log cat of my Code
After the line setContentView(R.layout.activity_main); add the following :-
dbn = new DbNeed(this);
This will instantiate (set) dbn which has at this stage only been declared and is therefore null.
I have recently started programming for android. I am writing a simple customadapter class in an app. The problem is that the adapter is not displaying any text in the listview. The logcat shows no error messages, but still the app is not working as expected.
I am including snippets of my code files for reference-
Reportcard.java
package com.example.jsk.myreportcard;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import java.util.ArrayList;
public class Reportcard extends AppCompatActivity {
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reportcard);
ArrayList<Result>s=new ArrayList<Result>();
s.add(new Result("Science","A")); s.add(new Result("Maths","A"));
ReportAdapter adapter=new ReportAdapter(this, s);
ListView l=(ListView)findViewById(R.id.list);
l.setAdapter(adapter);
}
}
Result.java
package com.example.jsk.myreportcard;
public class Result {
private String subject,grade;
public Result(String subjec, String grad)
{
subjec=subject;
grad=grade;
}
public String getSubject()
{
return subject;
}
public String getGrade()
{
return grade;
}
}
ReportAdapter.java
package com.example.jsk.myreportcard;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;
public class ReportAdapter extends ArrayAdapter<Result> {
public ReportAdapter(Activity context, ArrayList<Result>w) {
super(context, 0, w);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v=convertView;
if(v==null)
{
v= LayoutInflater.from(getContext()).inflate(R.layout.lay_text,parent,false);
}
Result res=getItem( position);
TextView sub=(TextView)v.findViewById(R.id.t1);
sub.setText(res.getSubject());
TextView grad=(TextView)v.findViewById(R.id.t2);
grad.setText(res.getGrade());
// return super.getView(position, convertView, parent);
return v;
}
}
Now the layout files-
reportcard.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/list"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
lay_text.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:id="#+id/lay">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/t1"
tools:text="hello"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/t2"
tools:text="World"/>
</LinearLayout>
Please help me to get this app working .
Thanks
You are not assigning values in constructor , you are assigning default values of Stings i.e null to local variable subjec and grad
public Result(String subjec, String grad)
{
subjec=subject; // yourvalue = null
grad=grade; // yourvalue = null
}
should be
public Result(String subjec, String grad)
{
subject=subjec; // datafield = yourvalue
grade=grad; // datafield = yourvalue
}
I'm interested in how you can change the size of the text in the list and then add it to the ListView. I'm using a list_item with custom layout . The question is how you can set the size of the text before it gets into the ListView. I hope for your help.
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android1="http://schemas.android.com/apk/res/android">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/shop_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1"
/>
<TextView
android:id="#+id/shop_address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="2"
/>
</LinearLayout>
</LinearLayout>
day_list_events.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:id="#+id/layout"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/day_and_data"
android:text="Перелік клієнтів на сьогоднішній день."
android:textStyle="bold"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/help_info"
android:text="(Щоб отримати інформацію про клієнта та оформити замовлення - натисніть на відповідного клієнта у списку)"
android:textColor="#A0A0A0"
/>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/day_list_event"
>
</ListView>
</LinearLayout>
DayListEventsActivity.java
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Window;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class DayListEventsActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.day_list_events);
sharedPreferences = getSharedPreferences("impInfo", Context.MODE_PRIVATE);
Resources res = this.getResources();
ArrayList<HashMap<String, String>> dayShopsInfo = new ArrayList<HashMap<String, String>>();
String[] shopName = res.getStringArray(R.array.shop_name);
String[] shopAddress = res.getStringArray(R.array.shop_address);
for(int i = 0; i < shopName.length; i++){
HashMap<String, String> dayShopsInfoCont = new HashMap<String, String>();
dayShopsInfoCont.put(KEY_SHOP_NAME, shopName[i]);
dayShopsInfoCont.put(KEY_SHOP_ADDRESS, shopAddress[i]);
System.out.println(i+" "+shopName[i]+" "+shopAddress[i]);
dayShopsInfo.add(dayShopsInfoCont);
}
ListView shopList = (ListView)findViewById(R.id.day_list_event);
SimpleAdapter shopListAdapter = new SimpleAdapter(this,
dayShopsInfo,
R.layout.list_item,
new String[]{KEY_SHOP_NAME, KEY_SHOP_ADDRESS},
new int[]{R.id.shop_name, R.id.shop_address});
shopList.setAdapter(shopListAdapter);
shopList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
private final String KEY_SHOP_NAME = "shop name";
private final String KEY_SHOP_ADDRESS = "shop address";
private SharedPreferences sharedPreferences;
}
UPDATE (Solution).
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class DayListEventsActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.day_list_events);
sharedPreferences = getSharedPreferences("impInfo", Context.MODE_PRIVATE);
Resources res = this.getResources();
ArrayList<HashMap<String, String>> dayShopsInfo = new ArrayList<HashMap<String, String>>();
String[] shopName = res.getStringArray(R.array.shop_name);
String[] shopAddress = res.getStringArray(R.array.shop_address);
for(int i = 0; i < shopName.length; i++){
HashMap<String, String> dayShopsInfoCont = new HashMap<String, String>();
dayShopsInfoCont.put(KEY_SHOP_NAME, shopName[i]);
dayShopsInfoCont.put(KEY_SHOP_ADDRESS, shopAddress[i]);
System.out.println(i+" "+shopName[i]+" "+shopAddress[i]);
dayShopsInfo.add(dayShopsInfoCont);
}
ListView shopList = (ListView)findViewById(R.id.day_list_event);
MySimpleAdapter shopListAdapter = new MySimpleAdapter(this,
dayShopsInfo,
R.layout.list_item,
new String[]{KEY_SHOP_NAME, KEY_SHOP_ADDRESS},
new int[]{R.id.shop_name, R.id.shop_address});
shopList.setAdapter(shopListAdapter);
shopList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
public class MySimpleAdapter extends SimpleAdapter{
public MySimpleAdapter(Context context,
List<? extends Map<String, ?>> data,
int resource,
String[] from, int[] to) {
super(context, data, resource, from, to);
}
#Override
public View getView(int position, View convertView, ViewGroup parent){
View returnView = super.getView(position, convertView, parent);
TextView shopName = (TextView)returnView.findViewById(R.id.shop_name);
shopName.setTextSize(20.0f);
return returnView;
}
}
private final String KEY_SHOP_NAME = "shop name";
private final String KEY_SHOP_ADDRESS = "shop address";
private SharedPreferences sharedPreferences;
}
Simply do this in the getView() method of the Adapter, to set the font size.
tv.setTextSize(20.0f);
If you are using xml for setting layout for list_item and there you have TextView you can change the size of the text like this:
<TextView
android:id="#+id/text_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp" /> // This is a size of your text
There's not "size of text"
You can change the size of the text inside the TextView:
Add:
android:textSize="16sp"
TO your XML
Or you can do it by code in the getView() method in the Adapter:
YOUR_TEXTVIEW.setTextSize(16);
I know this might be a little late, however I noticed that everyone forgot something in their answers. the method setTextSize takes 2 parameters for it's input. The second if a float that is the number of the size you want. The first is a TypedValue Constant to let specify what the number means ie: pixels, dip, sp, etc... so for the setTextSize set to 18sp it would look something like this:
TextView yourTextView = (TextView)findViewById(R.id.yourTextViewId);
yourTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,18)
and you would do it in the getView of the ArrayAdapter. Hope this helps someone else who was looking for an answer and stumble upon this one.
Try this one
TextView textView = (TextView) findViewById (R.id.yourTextViewId);
textView.setTextSize(18);
In my project whenever I extend activity it works fine but as soon as I extend ListActivity it throws exception and shows file not found. Why is that? We already know that ListActivity itself extends the Activity class. The application must run fine.
Here's the java file:
package com.android.feedGrabber;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import com.sun.cnpi.rss.elements.Item;
import com.sun.cnpi.rss.elements.Rss;
import com.sun.cnpi.rss.parser.RssParser;
import com.sun.cnpi.rss.parser.RssParserFactory;
public class feedGrabber extends Activity {
public static Collection<Item> readRSSDocument(String url) throws Exception {
RssParser parser = RssParserFactory.createDefault();
URL feedUrl = new URL(url);
URLConnection urlc=feedUrl.openConnection();
urlc.setRequestProperty("User-Agent","");
urlc.connect();
Rss rss = parser.parse(urlc.getInputStream());
return rss.getChannel().getItems();
}
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int links=0;
try
{
for(Item item : feedGrabber.readRSSDocument("http://feeds.feedburner.com/Tutorialzine")){
if(links++>3)
break;
TextView t = (TextView)findViewById(R.id.title);
t.append("Title: ");
t.append(item.getTitle().toString());
t.append("\n\n");
//System.out.println("Title: " + item.getTitle());
//System.out.println("Link: " + item.getLink());
}
}catch(Exception e)
{
//
}
}
}
If I change "extends Activity" to "extends ListActivity" it gives the exception. I need to bring this change because I want to implement it on ListView instead of TextView.
Error it throws:
debug mode gets active and it highlights under Suspended(exception RunTimeException): ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663.
When you extend a ListActivity, it is expecting the Layout to have a ListView that has an id of "#android:id/list", if you do not have it, it will throw an exception
You layout should look something like this:
<?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="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="#android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/noresults"/>
</LinearLayout>
Without seeing your main.xml or the exception I can't be sure, but I'd suggest checking if your list has the #android:id/list identity as required.