我對android非常陌生。我的項目需要我創建一個列表視圖,並根據用戶的選擇更改其他視圖中的多個數據片段。所以說,我從列表中選擇一個人的名字。我想要更改ImageButton圖像,TextView,併爲該特定人員連接一個數組。我一直在用戶選擇的字符串上使用文本處理,並確保我的資源符合某種格式。但是,我覺得應該有更好的方法。如果你不能說,我也是編程新手。如何從連接了多個信息的數組中創建列表視圖?
我正在尋找最簡單但有效的解決方案。
編輯:下面是一些代碼WRT一個數組稱爲人的名單:
// Handles User Selection of People
peopleList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Get Selection String
person1SavedText = people[position];
// Modify String to match corresponding resources and values
String people1ImageParsed = person1SavedText.toLowerCase().replace(" ", "").replace("-", "");
// Person 1 Image Uri/String
person1ImageUriString = "android.resource://org.example.person/drawable/" + person1ImageParsed;
person1ImagePath = Uri.parse(person1ImageUriString);
// Person 1 Array Uri/String
person1ArrayUriString = "android.resource://org.example.person/values/" + person1ImageParsed;
}
}
顯示一些代碼。 –
另外我明白你需要檢查出Android教程,以這兩個'http:// developer.android.com/resources/tutorials/hello-world.html'和'http://developer.android.com/ resources/tutorials/notepad/index.html' – havexz