`
sillycat
  • 浏览: 2527252 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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
分享到:
评论

相关推荐

    Sed - An Introduction and Tutorial by Bruce Barnett

    标题与描述:“Sed - An Introduction and Tutorial by Bruce Barnett” Sed,即Stream Editor(流编辑器),是一种功能强大的文本处理工具,广泛应用于Unix和类Unix系统中。它能够读取输入流,对其进行一系列预...

    Android.Application.Development.in.Detail.epub

    The book contains some recipes of the Android application development and examples, it considers the work in the Eclipse IDE and the Android Studio IDE, as well as the development of mobile websites ...

    Independent Component Analysis_ A Tutorial Introduction

    **标题**:“Independent Component Analysis_ A Tutorial Introduction”(独立成分分析:教程简介) **描述**:MIT关于信号盲源分离理论的经典著作,适用于研究生学习。 通过标题与描述可以看出,该书是关于独立...

    OpenGL ES Tutorial for Android.zip

    OpenGL ES Tutorial for Android – Part I – Setting up the view OpenGL ES Tutorial for Android – Part II – Building a polygon OpenGL ES Tutorial for Android – Part III – Transformations OpenGL ES ...

    android tutorial

    **4. 数据存储** Android支持多种数据存储方式,如SQLite数据库、SharedPreferences、文件系统和网络存储。理解何时使用这些方法并熟悉它们的操作,对处理用户数据至关重要。 **5. 异步处理与多线程** Android主线...

    Raspberry Pi - Tutorial 1 - An Introduction.mp4

    树莓派入门视频,初学者可以参考视频学习树莓派开发,逐步加入到技术开发环节,全英文视频,对英语学习者也是可以参考与学习的

    android tutorial hello world

    这是我自己学习android的作品. 共享一下, 需要的朋友可拿去参考一下. Android中的tutorials比较详细,但是没有提供实例. 如果操作中有什么地方搞错了,比较难查问题,特别是初学者. 我提供这个下载也是方便大家在学习时...

    Android Studio 3.2 Development Essentials, Kotlin Edition

    Android Studio 3.2 Development Essentials – Kotlin Edition 版本: Developing Android 9 Apps Using Android Studio 3.2, Kotlin and Android Jetpack By 作者: Neil Smyth ISBN-10 书号: 0960010939 ISBN-13 ...

    tutorial-android

    在Android开发领域,"tutorial-android"很可能是一个针对初学者的教程集合,旨在帮助新手逐步掌握Android应用开发的基础知识。这个教程可能涵盖了从安装开发环境到编写第一个应用的全过程,包括了各种关键概念、工具...

    android_ffmpeg_tutorial01

    本教程"android_ffmpeg_tutorial01"旨在教你如何将FFmpeg移植到Android应用中,并实现基本的图片显示功能。 首先,我们需要了解如何在Android Studio项目中集成FFmpeg。这通常涉及以下几个步骤: 1. **添加FFmpeg...

    Android sensors tutorial by touchquode

    首先,文件标题“Android sensors tutorial by touchquode”表明该文档是一份由***提供的Android传感器教程。这个教程很可能是介绍Android系统中如何使用各种传感器的应用和编程方法。同时,文件描述中的“***”...

    ns2 tutorial introduction

    4. 可选:安装Nam可视化工具,它可以帮助你以动画形式查看仿真结果。 三、学习路径 本教程采用逐步引导的方式,通过一系列简单的例子让你逐渐熟悉ns2。首先,你会学习如何创建基本的节点和连接,然后逐步引入更复杂...

    android-ffmpeg-tutorial

    本教程“android-ffmpeg-tutorial”旨在帮助你理解如何在Android应用中集成和使用FFmpeg进行多媒体操作。 首先,FFmpeg是一个跨平台的开源项目,包含一系列的命令行工具和一个C/C++库,支持各种常见的音视频编码...

    roman10-android-tutorial

    "roman10-android-tutorial" 是一个专门为Android初学者准备的教程项目,它包含了完整的源代码,可以帮助开发者深入了解Android应用开发的基本概念和技术。这个教程可能包括了从搭建环境到实现功能的各种实例,覆盖...

    63.[开源][安卓]roman10-android-tutorial-master

    63.[开源][安卓]roman10-android-tutorial-master roman10-android-tutorial包含了android tutorial的所有源代码。

    AndroidTutorialOosePdfFreeDownload.pdf 英文原版

    Android Tutorial Oose, Pdf Free Download

    android ndk tutorial

    - [简单的 Android NDK 教程](http://abitno.me/a-simple-tutorial-to-android-ndk) - [Android NDK 入门](http://article.yeeyan.org/view/105279/133784) - [Oracle 官方 JNI 文档]...

    Surpac Introduction Tutorial

    Surpac introduction tutorial

Global site tag (gtag.js) - Google Analytics