Android4.0.4编程日记(4)--List单击Intent跳转并获取数据
2013-01-22 14:27
363 查看
第二个页面的代码
package com.example.test; import com.example.pojo.Params; import android.app.Activity; import android.os.Bundle; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.TextView; import android.widget.Toast; import android.widget.ToggleButton; public class SecondActivity extends Activity{ TextView name; TextView note; ToggleButton controlButton; String id; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); name=(TextView) this.findViewById(R.id.itemNameValue); note=(TextView) this.findViewById(R.id.itemNoteValue); controlButton=(ToggleButton) this.findViewById(R.id.controlButton); Params p=(Params) getIntent().getSerializableExtra("params"); name.setText(p.getName()); note.setText(p.getNote()); id=p.getId(); controlButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub controlButton.setChecked(isChecked); if(isChecked){ Toast.makeText( getApplicationContext(), "开启"+id+"按钮成功", Toast.LENGTH_SHORT).show(); }else{ Toast.makeText( getApplicationContext(), "关闭"+id+"按钮成功", Toast.LENGTH_SHORT).show(); } } }); } }
第一个界面的单击事件
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent intent = new Intent(MainActivity.this,SecondActivity.class); //intent.setClass(ListViewActivity.this, ListActivity.class); intent.putExtra("params", list.get(arg2)); startActivity(intent); System.out.println("aaa"); }
第二个页面的xml activity_second.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:orientation="vertical" > </LinearLayout> <TextView android:id="@+id/itemNameValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/linearLayout1" android:layout_marginTop="15dp" android:layout_toRightOf="@+id/linearLayout1" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/itemNoteValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/itemNameValue" android:layout_below="@+id/itemNameValue" android:layout_marginTop="77dp" android:textAppearance="?android:attr/textAppearanceLarge" /> <ToggleButton android:id="@+id/controlButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/itemNoteValue" android:layout_alignParentBottom="true" android:layout_marginBottom="76dp" android:text="ToggleButton" /> </RelativeLayout>
相关文章推荐
- Android4.0.4编程日记(3)--ListView单击获取事件
- Android4.0.4编程日记(5)--URL网络链接获取数据
- 【Android数据传递】Intent传递List和Object和List<Object>(附源码)
- android学习日记05--Activity间的跳转Intent实现
- Android开发通过Xutil3获取数据并显示(list)
- Android学习笔记_46_Android的intent之间Object、List、List<Object>和全局变量数据的传递(Parcelable Serializable)
- Android编程获取图片数据的方法详解
- 【Android数据传递】Intent传递List和Object和List<Object>(附源码)
- 【Android数据传递】Intent传递List和Object和List<Object>(附源码)
- Android 使用Intent实现Activity跳转和数据传递
- Android网络编程之获取网络上的Json数据实例
- android 从activity用intent跳转到listactivity并在其中用simpleadapter在listview中显示数据列
- 在android中用 Intent 传递 List类型的数据(转)
- android中使用intent来实现Activity带数据跳转
- Android编程实现获取新浪天气预报数据的方法
- Android成长日记-使用Intent实现页面跳转
- 【Android数据传递】Intent传递List和Object和List<Object>(附源码)
- Android Post参数提交 List<NameValuePair>,web端获取数据
- android scheme 跳转应用 如何获取intent传的参数
- Android实现intent跳转界面传递数据(2)——onActivityResult方法接收返回值