我在寻找线性布局时遇到问题......这是 xml 布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:binding="http://www.gueei.com/android-binding/"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
tools:context=".controllers.ElencoInfrazioni" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Infrazione: " />
<Spinner
android:id="@+id/elencoInfrazioni"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TableLayout
android:id="@+id/tabellaDatiElencoInfrazioni"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:stretchColumns="*"
android:visibility="gone" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Art. 3: " />
<TextView
android:id="@+id/articolo3ElencoInfrazioni"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="non specificato"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/panelArticolo4ElencoInfrazioni"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Art. 4: " />
<TextView
android:id="@+id/articolo4ElencoInfrazioni"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="non specificato"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
....
处理布局的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.elenco_infrazioni);
init();
}
private void init() {
tabellaDati = (TableLayout) this
.findViewById(R.id.tabellaDatiElencoInfrazioni);
elencoInfrazioni = (Spinner) this.findViewById(R.id.elencoInfrazioni);
panelArticolo4 = (LinearLayout) this.
findViewById(R.id.panelArticolo4ElencoInfrazioni);
articolo3 = (TextView) this
.findViewById(R.id.articolo3ElencoInfrazioni);
articolo4 = (TextView) this
.findViewById(R.id.articolo4ElencoInfrazioni);
}
每个 findViewById 都可以,除了 LinearLayout panelArticolo4 给我 null...我需要线性布局来设置它的可见性..我做错了什么?
提前致谢