我想有一个listview项目(学生列表),我可以尽可能地实现它。我想有一个带有单选按钮列表的AlertDialog(家长开会的时隙),即listview项目的onClick,应该出现AlertDialog。如果我在AlertDialog上选择一个时隙,则该时隙应显示在listview项目上,该项目将显示AlertDialog。假设如果我单击listview item1(student-1)并显示(timeslots-AlertDialog),则当我单击AlertDialog中的第一个项目时,该项目应仅显示在该特定Listview项目上。这应该分别针对所有listview项目发生。请帮助我,我该怎么做。我尝试这样做,但目前我没有代码。如果有人知道这一点,请发送任何文档或发送代码来指导我。
public class StudentActivity extends Activity implements AlertDialogRadio.AlertPositiveListener {
ListView studentlistView;
TextView customerName;
List < BoxPojo > studentlist;
public ArrayList < String > displayTimeSlotList = new ArrayList < String > ();
String strSelectedPlan = "";
int position = 0;
CustomBoxAdapterList _customBoxAdapterList;
Context mContext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_prepaid);
getActionBar().setBackgroundDrawable(new
ColorDrawable(Color.parseColor("#034ea2")));
customerName = findViewById(R.id.prepaid_customer_name);
boxlistView = findViewById(R.id.lv_boxId);
}
//this function is called inside onPostExecute function where the
data is coming and filling inside lisview
public void fillListView() {
_customBoxAdapterList = new
CustomBoxAdapterList(getApplicationContext(), studentlist);
studentlistView.setAdapter(_customBoxAdapterList);
_customBoxAdapterList.notifyDataSetChanged();
studentlistView.setOnItemClickListener(new
AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView < ? > parent, View view, int position, long id) {
Log.e("clicked postion is", String.valueOf(position));
TextView textView = (TextView) view.findViewById(R.id.tv_boxIDData);
String val = textView.getText().toString();
FragmentManager manager = getFragmentManager();
AlertDialogRadio alert = new AlertDialogRadio();
Bundle b = new Bundle();
b.putInt("position", position);
alert.setArguments(b);
alert.show(manager, "alert_dialog_radio");
}
});
}
@Override
public void onPositiveClick(int position) {
String planDescr;
Cursor cursor = (Cursor)
MyBroadbandDatabase.getTimeSlotDescriptions();
cursor.moveToFirst();
ArrayList < String > listtt = new ArrayList < String > ();
if (cursor.getCount() > 0) {
listtt.add(String.valueOf(cursor));
timeSlot = cursor.getString(cursor.getColumnIndex("timeSlot"));
for (cursor.moveToFirst(); !cursor.isAfterLast();
cursor.moveToNext()) {
// The Cursor is now set to the right position
listtt.add(cursor.getString(0));
}
}
String str[] = new String[listtt.size()];
for (int j = 0; j < listtt.size(); j++) {
str[j] = listtt.get(j);
}
this.position = position;
displayTimeSlotList.clear();
displayTimeSlotList.add(str[this.position]);
int listviewPos = (int) studentlistView.getSelectedItemId();
slectedItemTimeSlot.setText(displayTimeSlotList.get(listviewPos));
}
}