一、Android的跳转
Intent intent =newIntent(context, LoginActivity.class);
intent.putExtra("Text","Hello World");//传递参数
context.startActivity(intent);
Bundle extras = getIntent().getExtras();
String mText = extras.getString("Text");//接收参数
Log.d("你好啊","i="+mText+",大家下午好 ");//输出参数
二、ListView
1、在XML文件中布局listview
<ListView
android:id="@+id/listView_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollingCache="false"
android:fadingEdge="none"
android:divider="@drawable/rectangle_edittext">
/*
2、定义数组来表示listView要显示,也是我们学习哪些常用的控件
*/
private static finalString[]commonFunList=newString[]{
"Everybody let us go !",
"Everybody let us go !",
};
3、对listView进行设置
listview=(ListView) findViewById(R.id.listView_list);
listview.setAdapter(newArrayAdapter(this,
android.R.layout.simple_list_item_1,
commonFunList));
//设置点击事件
listview.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override public void onItemClick(AdapterView adapterView, View view, int i, long l) {
Log.d("您点击了第",+ i + 1 +"个cell");
context.startActivity(intent); } } });
4、listView设置headerView
LayoutInflater lif = (LayoutInflater) getSystemService(this.LAYOUT_INFLATER_SERVICE);
View headerView = lif.inflate(R.layout.list_header,listview,false);
视图如下: