标签内容处理....如何在android系统? [英] tab content handling.... how in android?
问题描述
我有两个选项卡的tabactivity。
在此tabactivity我已经EDITTEXT和按钮,搜索本地数据库。
我有一个listactivity类作为tabcontent。它示出了由的FrameLayout
我想根据这是在tabactivity中的EditText输入的文本以刷新listactivity。
该怎么做?
我在listactivity创建的方法:
公共无效搜索(字符串TEMP){
字符串VAL =温度;
尝试{
C = BruTube_Videos.this.getContentResolver()查询(Constants.CONTENT_URI,空,Constants.TITLE +LIKE'%+ VAL +%',空,DATETIME(+ Constants.PUBLISHED +)DESC);
}赶上(例外五){
Log.v(TAG,EXP的光标);
}
显示(C);
}
在这样的tabactivity调用此方法:
的EditText ET1 =(EditText上)findViewById(R.id.EditText01);
字符串TEMP = et1.getText()的toString()。
BruTube_Videos vdo_obj =新BruTube_Videos();
vdo_obj.search(临时);
它显示了一个例外logcat的:
16 02-12:58:26.623:VERBOSE / BruTube_Videos(227):异常的brutube搜索:java.lang.IllegalStateException:之前的onCreate不向活动系统服务()
我如何管理呢?
感谢。
BruTube_Videos vdo_obj =新BruTube_Videos();
不要调用上的活动构造
。你永远不创建活动 - 你告诉Android的启动它们。那是你错误的根源。
我强烈建议你得到完全摆脱了活动,并有一个 TabActivity
持有到查看
- - 一个是为您编辑表单的布局,一个是你的的ListView
。然后,你就不会感到困惑的code去的地方,因为只有一个活动。这也更有效从编程,存储器,CPU和电池的利用率的角度来看
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.
这篇关于标签内容处理....如何在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!