다른 listView를 포함하는 listView를 표시해야합니다. 여기ListView를 포함한 ListView
내가 그것을 처음 목록보기 보여주기 위해 할 방법은 다음과 같습니다
public class myClas extends ListActivity {
private List<Order> listOrders = new ArrayList<Order>();
private ArrayList<HashMap<String, String>> orderList, orderItems;
private ProgressDialog pDialog;
/**
* First method called when the activity is created
* @param Bundle savedInstanceState contains the backup status recorded during the last execution of the activity
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_historic);
//hashmap
orderList = new ArrayList<HashMap<String, String>>();
orderItems = new ArrayList<HashMap<String, String>>();
//loading in the background
new LoadingOrders().execute();
}
/**
* Loading orders in the background
* */
class LoadingOrders extends AsyncTask<String, String, String> {
/**
* Before starting the thread in the background, a progress bar is displayed
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Historic.this);
pDialog.setMessage("Loading");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
/**
* Retrieving orders
* */
@Override
protected String doInBackground(String... args) {
//the first listView
for (int i = 0; i < listOrders.size(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("date", "date_exemple);
orderList.add(map);
//the second listView
for (int j = 0; j < order.getOrderItems().size(); j++) {
HashMap<String, String> mapItems = new HashMap<String, String>();
mapItems.put("textViewPrice", "price_exemple"));
mapItems.put("textViewStatus", "status_example");
orderList.add(map);
}
}
return null;
}
/**
* After completing the background tasks, remove the progress bar
* **/
@Override
protected void onPostExecute(String file_url) {
//The progress bar is removed
pDialog.dismiss();
// Update the user interface
runOnUiThread(new Runnable() {
@Override
public void run() {
//the first listView
//Updating orders
ListAdapter adapter = new SimpleAdapter(
MyClass.this, orderList,
R.layout.order, new String[] { "date"},
new int[] { R.id.textViewDate});
setListAdapter(adapter);
//the second listView
//OrderItems
**adapter = new SimpleAdapter(
MyClass.this, orderItems,
R.layout.order_item, new String[] { "textViewPrice", "textViewStatus"},
new int[] { R.id.textViewPrice, R.id.textViewStatus});
setListAdapter(adapter);**
}
});
}
}
}
첫 번째 목록보기를 들어, 괜찮아요,하지만 실패 (두 번째 어댑터 **와) 끝에 선. 이 두 번째 어댑터를 사용할 수 있을지 모르겠다. ...
어떻게 할 수 있습니까?
감사합니다.
이것은 하나의 목록을 다른 목록에 보관하는 것은 좋지 않은 생각입니다. 대신 행에 여러 선형 레이아웃이있는 목록 하나를 사용해보십시오. –
이상하게 생각하지만 불가능하지 않습니까? 그렇지 않으면, 내가 줄 지어있는 평평한 선로로 그것을 어떻게 할 수 있냐? – user2021346
두 개의 스크롤 막대에 동시에 문제가 생길 수 있으므로 expandablelistview 사용을 고려하십시오. – AlexBcn