android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_margin="10dip"
tools:context=".MainActivity" >
</EditText>
layout1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);
View myLoginView = layoutInflater.inflate(R.layout.alert_main, null);
Dialog alertDialog = new AlertDialog.Builder(MainActivity.this).
setTitle("身高").
setView(myLoginView).
setPositiveButton("保存", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).
create();
alertDialog.show();
}});
layout3.setOnClickListener(new OnClickListener(){
private int selectedFruitIndex = 0;
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
final String[] arrayFruit = new String[] { "蘋果", "橘子", "草莓", "香蕉" };
Dialog alertDialog = new AlertDialog.Builder(MainActivity.this).
setTitle("你喜歡喫哪種水果?").
setIcon(R.drawable.ic_launcher)
.setSingleChoiceItems(arrayFruit, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
selectedFruitIndex = which;
}
}).
setPositiveButton("確認", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, arrayFruit[selectedFruitIndex], Toast.LENGTH_SHORT).show();
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).
create();
alertDialog.show();
}});
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dip"
android:paddingLeft="16dip"
android:paddingTop="10dip"
android:text="基礎數據"
android:textColor="#888"
android:textSize="16dip" />
<LinearLayout
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background2"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="16dip"
android:text="身高"
android:textSize="16dip" />
<TextView
android:id="@+id/height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dip"
android:text="180"
android:textColor="#888"
android:textSize="16dip" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background2"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="16dip"
android:text="性別"
android:textSize="16dip" />
<TextView
android:id="@+id/height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dip"
android:text="男"
android:textColor="#888"
android:textSize="16dip" />
</LinearLayout>
</LinearLayout>
</ScrollView>