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>
399

被折叠的 条评论
为什么被折叠?



