Я видел несколько примеров (here) SwipeViews, которые реализованы в ListView, но они предназначены для отдельных элементов в списке, а не для самого ListView.Android - Использование SwipeView для всего ListView
В моем приложении намерение запускается из одного элемента Listview и отправляет вас в рассматриваемый список. Оттуда я хотел бы реализовать какую-то функцию, которая позволяет мне перебирать из одного ListView в другой. В этом случае развёртывание с намерениями не обеспечило бы удобного для пользователя опыта, так как SwipeView.
Если я не объяснил это четко, пожалуйста, дайте мне знать. Если мне нужно создать дополнительные классы и файлы макета XML, чтобы сделать это, то пусть будет так.
CustomListAdapter.java (класс, который содержит код ListView)
public class CustomListAdapter extends ArrayAdapter<String> {
private Context mContext;
private int id;
private ArrayList<String> callData;
private String[] headers = {"Number", "Customer Number", "Name", "Bill to Customer Number", "Bill to Name",
"Order Date", "Order Time", "Response Date", "Response Time", "Fix by Date", "Fix by Time",
"Responded Date", "Responded Time", "Fixed Date", "Fixed Time", "Your Reference",
"Description", "Transaction Status", "Ship to Code", "Ship to Name", "Ship to Address",
"Ship to Address 2", "Ship to City", "Ship to County", "Ship to Postcode", "Contact Name",
"Phone Number", "Note", "Sources"};
public CustomListAdapter(Context context, int textViewResourceId, ArrayList<String> callData) {
super(context, textViewResourceId, callData);
this.callData = callData;
}
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.list_service_order, null);
}
String test = callData.get(position);
if (test != null) {
TextView customerNoLabel = (TextView) view.findViewById(R.id.name_label);
TextView customerNoData = (TextView) view.findViewById(R.id.listed_data);
if (customerNoLabel != null) {
customerNoLabel.setText(headers[position]);
customerNoData.setText(callData.get(position));
}
}
return view;
}
}
CallActivity2.java (класс, который реализует код для CustomListAdapter и который я хочу использовать салфетки для двух различных ListView с различными заголовки и значения)
public class CallActivity2 extends ListActivity {
private ArrayList<String> individualCallData;
// private ArrayAdapter<String> callDataAdapter;
private CustomListAdapter callDataAdapter;
private ListView callDataView;
private Runnable viewParts;
private TextView serviceOrderNo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.call_display);
Intent intent = getIntent();
individualCallData = intent.getStringArrayListExtra("Call");
// Instantiate CustomListAdapter class
callDataView = (ListView) findViewById(android.R.id.list);
callDataAdapter = new CustomListAdapter(this, R.layout.list_service_order, individualCallData);
setListAdapter(callDataAdapter);
viewParts = new Runnable(){
public void run(){
handler.sendEmptyMessage(0);
}
};
// here we call the thread we just defined - it is sent to the handler below.
Thread thread = new Thread(null, viewParts, "MagentoBackground");
thread.start();
}
private Handler handler = new Handler() {
public void handleMessage(Message msg)
{
// create some objects
// here is where you could also request data from a server
// and then create objects from that data.
//individualCallData.add("Test");
callDataAdapter = new CustomListAdapter(CallActivity2.this, R.layout.list_service_order, individualCallData);
// display the list.
setListAdapter(callDataAdapter);
}
};
}
Являются ли два списка, которые прокручиваются между основным и подробным списками (т. Е. Соответствует ли элемент списка в первом списке его собственному списку)? Или два списка не связаны? – Bryan