![](/img/trans.png)
[英]How To Show specific Data From SQLite Database In Android ListView
[英]How to show SQLite data in ListView in android? search business app
我是Java编程和此网站的新手。 这是我的第二个程序,但是我一直坚持让SQLite数据显示在ListView项目中。 我的程序显示了业务范围,然后详细显示了选定的业务,对不起,我无法发布照片。
我将不得不描述它。
首先,ListView业务列表:每个ListView项目中有2个单元格。 左边的单元格有公司照片,右边的单元格有3条信息:公司名称(以粗体显示,较大的文本),地址(以较小的文本显示,可选)和评分(以5星表示)
二,精选业务详细:
全屏显示所选企业的详细信息。 左上方的单元格是照片,右上方的单元格具有与ListView相同的信息,并在顶部的单元格下方显示说明,联系信息和地图。
我想在ListView中拥有商家名称,地址和等级,并且数据必须来自SQLite。 我该怎么做? 请帮我。 提前致谢!!! 我尝试了以下代码,但是没有用。
public class ListViewItems extends Activity {
TextView textViewHotClubs;
Button btnSortAtoZ;
Button btnSortTopRated;
Button btnNearU;
ListView listView1;
ArrayList<Integer> images = new ArrayList<Integer>();
ArrayList<String>strArray=new ArrayList<String>();
ArrayList<Object> ObjectArray = new ArrayList<Object>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view_items);
listView1=(ListView)findViewById(R.id.listView1);
textViewHotClubs=(TextView)findViewById(R.id.textViewHotClubs);
btnNearU=(Button)findViewById(R.id.btnNearU);
btnSortAtoZ=(Button)findViewById(R.id.btnSortAtoZ);
btnSortTopRated=(Button)findViewById(R.id.btnSortTopRated);
listView1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
String getText=strArray.get(arg2);
if(getText=="Code")
{
Intent i=new Intent(ListViewItems.this, CodeClub.class);
i.putExtra("pushText","Code");
startActivity(i);
}
else if (getText=="Club Duo")
{
Intent i = new Intent(ListViewItems.this,ClubDuo.class);
i.putExtra("pushText", "Club Duo");
startActivity(i);
}
}
});
strArray.clear();
images.clear();
strArray.add("Code");
strArray.add("Club Duo");
images.add((int)R.drawable.dragon30x33);
images.add((int)R.drawable.rainbow30x20);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.list_view_items, menu);
return true;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.