Android Tutorial(4)Detail Page Introduction

Some Tips:
1. How to browse the database sqlite on Android.
Solution:
Download the software for MAC from here http://sourceforge.net/projects/sqlitebrowser/?source=dlp

The name of the file is sqlitebrowser_200_b1_osx.zip.

And directly open the data file from Android. From eclipse, choose the DDMS and then go to File Explorer
/data/data/com.sillycat.packagename/databases/DataBaseName

That is nice.

How to Add Detail Link to my List Pages.
There are 2 ways to do that.
1. Add Click Listener to the Item
In the refresh state of the List page.
publicvoid refreshStates(final List<ILPLocation> items) {
if (items == null || items.isEmpty()) {
return;
}
LocationsListAdapter adapter = new LocationsListAdapter(this, items);
setListAdapter(adapter);

ListView lv = getListView();
lv.setOnItemClickListener(new ListView.OnItemClickListener(){
publicvoid onItemClick(AdapterView<?> parent, View view, int position,long id) {
ILPLocation item = items.get(position);
Log.d(TAG, "You are hitting item Name= " + item.getName() + " id = " + item.getID().getValue());
Intent i = new Intent(getApplicationContext(), LocationDetailActivity.class);
i.putExtra(LOCATION_NAME, item.getID().getValue());
startActivity(i);
}

});
}

In the setOnItemClickListener I set the onItemClick method, start an Intent, and pass one parameter as the ID to the activity.

2. Define a Button, and Put the Activities in the OnClick Area
final Button button = (Button) findViewById(R.id.button_checkin);
button.setOnClickListener(new View.OnClickListener() {
publicvoid onClick(View view) {
String id = ((TextView) findViewById(R.id.location_id)).getText().toString();
Log.d(TAG,"Hitting the checkin button and get the location of id = "+ id);
…snip…
}
});

3. How We Receive the Message and Parameter
In the create lifecycle:
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
…snip…
Intent i = getIntent();
String id = i.getStringExtra(ChangeMeActivity.LOCATION_NAME);
…snip…



References:
http://www.androidhive.info/2011/10/android-listview-tutorial/
http://www.javacodegeeks.com/android/android-core
http://stackoverflow.com/questions/2965698/listview-setonitemclicklistener-and-setonitemselectedlistener-to-store-the-selec

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android webkit 网页标签的解析与预下载
  2. Android(安卓)StudioV3.2.1的两种模式及
  3. android手机屏幕横竖屏切换禁止调用生命
  4. 转载:Android中如何修改系统时间(应用程序
  5. Android(安卓)5.0(Lollipop)中的SurfaceT
  6. 【android】 百度地图应用开发(一)
  7. 初学Android——闪光灯当做手电筒使用
  8. Ruby实现Android自动化屏幕适配
  9. 深入浅出Android(安卓)Handler
  10. Android(安卓)之Sub Menu案例