开发者

tab content handling.... how in android?

开发者 https://www.devze.com 2022-12-20 06:08 出处:网络
i have a tabactivity with two tabs. in this tabactivity i have edittext and button to search the local database.开发者_如何转开发

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消