Android Tutorial(4)Detail Page Introduction

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值