我正在嘗試創建一個行佈局,其中每個列表項都有一個要遵循的模板。目前我有這個,它允許我在每個列表中顯示一行文本。Android XML佈局問題
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="20sp"
android:padding="100dp" >
</TextView>
然而,當我試圖改變它,讓我增加更多的項目,如圖像按鈕和更多的文本字段,它總是不允許我進行編譯。
我試着developer.android的網站是拿一塊XML從一個教程,
<?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="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
android:textSize="16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
但它引發了我的錯誤,說明 - 處理指令目標匹配「[XX] [MM] [11] 「不允許 。 - 錯誤:解析XML錯誤:XML或文本聲明不在實體的開始
有人可以幫助我嗎?我不太確定這個錯誤的含義。
UPDATE:
什麼,我試圖做的是有像右側的邊欄,顯示的項目清單,與我張貼的第一個XML片段,我能拿到我想要的結果,但我無法對其進行任何更改。
package com.project.test;
import android.app.ListFragment;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class TestListFragment extends ListFragment {
String [] Items = {"Item A", "Item B", "Item C"};
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(getActivity(),
R.layout.listtemplate, Items));
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.i("FragmentList", "Item clicked: " + id);
}
}
不更新你的問題,使它成爲完全不同的一個。馬茲的回答是100%正確的,現在它是多餘的。你應該已經標記了它的答案並開始了一個新的問題。 – Blundell