我在做什麼錯在下面。也是繼是我的問題Android佈局問題
1.In一個main.xml中的文件纔能有兩個線性佈局或故事佈局
2.Below上的Button1點擊我設置linearlayout1的知名度,「隱身」,但它不發生。
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button g_gal =(Button)findViewById(R.id.button1);
final LinearLayout tr1 =(LinearLayout)findViewById(R.id.linearLayout1);
final LinearLayout tr2 =(LinearLayout)findViewById(R.id.linearLayout2);
tr2.setVisibility(View.INVISIBLE);
final Button g_gal =(Button)findViewById(R.id.button1);
g_gal.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
try {
tr2.setVisibility(View.VISIBLE);
tr1.setVisibility(View.INVISIBLE);
}
catch (Exception e)
{
Toast.makeText(getApplicationContext(),"Exception while displaying gallery: "+ e, Toast.LENGTH_SHORT).show();
}
}
});
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<Button android:text="Browse Gallery" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<requestFocus></requestFocus>
</EditText>
<Button android:text="Send SMS to Nav" android:id="@+id/sms" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Back" android:id="@+id/back1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>