android Fragment怎么取得sqlite里面的内容
publicclassFragment1extendsFragment{publicViewonCreateView(LayoutInflaterinflater,Vie...
public class Fragment1 extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tag, container, false);
tianjiabl = (ImageButton)view.findViewById(R.id.tianjiabl);
imagejc = (ImageButton)view.findViewById(R.id.imagejc);
GetData getData = new GetData();
getData.getListView();
tianjiabl.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(getActivity(), AddIDActivity.class);
startActivity(intent);
}
});
return view;
}
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
}
class GetData extends ListFragment{
private SimpleCursorAdapter adapter;
@Override
public ListAdapter getListAdapter() {
// TODO Auto-generated method stub
return super.getListAdapter();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
CreationDb helpter = new CreationDb(getActivity());
Cursor c = helpter.query();
String[] from = {"person","name","gender","age","detection"};
int[] to = {R.id.textid,R.id.textname,R.id.textgender,R.id.textage,R.id.textxm};
adapter = new SimpleCursorAdapter(getActivity(),
R.layout.item1, c, from, to);
}
} 展开
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tag, container, false);
tianjiabl = (ImageButton)view.findViewById(R.id.tianjiabl);
imagejc = (ImageButton)view.findViewById(R.id.imagejc);
GetData getData = new GetData();
getData.getListView();
tianjiabl.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(getActivity(), AddIDActivity.class);
startActivity(intent);
}
});
return view;
}
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
}
class GetData extends ListFragment{
private SimpleCursorAdapter adapter;
@Override
public ListAdapter getListAdapter() {
// TODO Auto-generated method stub
return super.getListAdapter();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
CreationDb helpter = new CreationDb(getActivity());
Cursor c = helpter.query();
String[] from = {"person","name","gender","age","detection"};
int[] to = {R.id.textid,R.id.textname,R.id.textgender,R.id.textage,R.id.textxm};
adapter = new SimpleCursorAdapter(getActivity(),
R.layout.item1, c, from, to);
}
} 展开
2个回答
2013-11-23
展开全部
你想达到什么效果。
你是用什么方法来操纵sqlite的。
更多追问追答
追问
我只想把sqlite里面的内容通过list显示在一个Fragment上
追答
你是不会显示还是不会查询数据库?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
好像需要内容提供器(content provider)才能访问sqlite里面的东西,具体的你再搜一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |