views:

758

answers:

1

hi all,

i have a tabactivity with two tabs.

in this tabactivity i have edittext and button to search the local database.

i have a listactivity class as a tabcontent. it shows by the framelayout.

i want to refresh that listactivity based on the text entered in edittext which is in the tabactivity.

how to do that?

i created a method in a listactivity :

public void search(String temp) {
String val=temp;
try{
c=BruTube_Videos.this.getContentResolver().query(Constants.CONTENT_URI, null, Constants.TITLE+" like '%"+val+"%'", null, "DATETIME("+Constants.PUBLISHED+") DESC");
}catch(Exception e){
Log.v(TAG, "exp in cursor");
}
show(c);
}

invoke this method in a tabactivity like this:

EditText et1=(EditText) findViewById(R.id.EditText01);
String temp=et1.getText().toString();
BruTube_Videos vdo_obj=new BruTube_Videos();
vdo_obj.search(temp);

it shows an exception in logcat:

02-12 16:58:26.623: VERBOSE/BruTube_Videos(227): Exception in brutube search:java.lang.IllegalStateException: System services not available to Activities before onCreate()

how can i manage it?

thanks.

+1  A: 
BruTube_Videos vdo_obj=new BruTube_Videos();

Never call a constructor on an Activity. You never create activities -- you tell Android to start them. That is the source of your error.

I strongly encourage you to get rid of the activities altogether, and have a single TabActivity holding onto Views -- one that is a layout for your edit form, one that is your ListView. Then, you will not get confused as to where the code goes, since there is only one activity. This is also more efficient from a programming, memory, CPU, and battery utilization standpoint.

CommonsWare
hi thanks for reply.. i have customized layouts for a single list item. so i must be use the customized simpleCursorAdapter. how can i use a cursoradapter in listview. give me some code examples.
Praveen Chandrasekaran
here the view will change dynamically depends on the cursor input...
Praveen Chandrasekaran
Can anyone provide some code detailing how to do this? It's not clear how to do this, even using views.
greg7gkb