ListView,3行
来源:互联网 发布:淘宝子账号权重值500 编辑:程序博客网 时间:2024/06/08 15:06
1.MainActivity
public class MainActivity extends Activity implements OnClickListener{
private Button button;
private EditText editText1;
private EditText editText2;
private EditText editText3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
// new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1);
button=(Button) findViewById(R.id.button);
editText1=(EditText) findViewById(R.id.edit_text1);
editText2=(EditText) findViewById(R.id.edit_text2);
editText3=(EditText) findViewById(R.id.edit_text3);
button.setOnClickListener(this);
}
@Override
public void onClick(View v){
switch(v.getId()){
case R.id.button:
// 在此添加逻辑
String inputText1=editText1.getText().toString();
String inputText2=editText2.getText().toString();
String inputText3=editText3.getText().toString();
Intent intent=new Intent(MainActivity.this,BiaoActivity.class);
intent.putExtra("extra_data1", inputText1);
intent.putExtra("extra_data2", inputText2);
intent.putExtra("extra_data3", inputText3);
startActivity(intent);
break;
default:
break;
}
}
}
2.BiaoActivity
public class BiaoActivity extends Activity{
// private ListView listView;
private ListView mListView;
private SimpleAdapter mAdapter;
private List<HashMap<String, Object>> mHashMaps;
private HashMap<String, Object> map;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.biaoge);
mListView=(ListView) findViewById(R.id.list);
mAdapter = new SimpleAdapter(this, getData(), R.layout.biao_item, new String[]{ "t1", "t2","t3"},
new int[]{ R.id.t1, R.id.t2,R.id.t3});
mListView.setAdapter(mAdapter);
}
private List<HashMap<String, Object>> getData() {
mHashMaps = new ArrayList<HashMap<String,Object>>();
map = new HashMap<String, Object>();
Intent intent1=getIntent();
String inputText1=intent1.getStringExtra("extra_data1");
String inputText2=intent1.getStringExtra("extra_data2");
String inputText3=intent1.getStringExtra("extra_data3");
map.put("t1", inputText1);
map.put("t2", inputText2);
map.put("t3", inputText3);
mHashMaps.add(map);
map = new HashMap<String, Object>();
map.put("t1", "G2");
map.put("t2", "google 2");
map.put("t3", "G2");
mHashMaps.add(map);
return mHashMaps;
}
}
3.man_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机号" />
<EditText
android:id="@+id/edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="手机号"
/>
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机号" />
<EditText
android:id="@+id/edit_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="手机号"
/>
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机号" />
<EditText
android:id="@+id/edit_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="手机号"
/>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册"
/>
</LinearLayout>
4.biaoge
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
5.biao_item
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
- ListView,3行
- 【listview精深系列3】listview的优化
- WPF-ListView选中行
- ListView选中行
- listview定位行
- ListView获取双击行
- ListView 多行选择
- listview增加行
- 更新ListView某一行
- ListView 上下移动行
- listview 行高设置
- listview固定行高
- listview添加行
- ListView全行选择
- ListView(3)
- 3D ListView
- ListView详解3
- ListView的优化(3)
- 不解压直接读取压缩包中的文件
- 菜鸟学Android(四十四):jsp标签技术简介及jsp标签的开发详解
- HTTPS、SPDY和HTTP/2的性能比较
- Python 爬虫
- Android 谷歌 开源 通信框架 VOLLEY(六)——应用实例
- ListView,3行
- Lttng document
- FZU 2167 大王叫我来巡山呐
- 关于ScrollView的知识
- 如何使用crontab定时运行爬虫
- 选择排序小谈
- Linear Regression_Note of Machine Learning_Andrew NG
- VC6.0使用richedit2.0 or richedit3.0
- 火狐 Flex 用jsp导出EXCL表格乱码