-1
Hier klicken ich auf Schulbesuch arbeitete, wo ich will (wenn ich das erste Element der Listenansicht geklickt wird alles fehlt oder all Anwesenden markieren) ich dies bereits getan mit button außerhalb von listview aber ich möchte es mit dem ersten listview ohne taste.wie das Element der Listenansicht ändern, indem erstes Element der Listenansicht in android
public class StudentsAttendanceActivity extends AppCompatActivity implements AsyncResponse, SwipeRefreshLayout.OnRefreshListener {
public StudentsAttendanceAdapter mAttendanceAdapter;
public ArrayList<StudentsAttendenceModel> mListInfo = new ArrayList<>();
int index, mTop,mEmployeeId;
View mRootView;
public int classId;
//private SwipeRefreshLayout swipeLayout;
private ListView mListView;
String className;
String classIdNo;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.students_attendance_layout);
//mRootView = inflater.inflate(R.layout.students_attendance_layout, false);
//swipeLayout=(SwipeRefreshLayout) mRootView.findViewById(R.id.swipe_container);
mListView = (ListView) findViewById(R.id.studentsList);
final Button allStudentSelectionButton = (Button) findViewById(R.id.allStudentSelectionButton);
allStudentSelectionButton.setTag("Present");
//ListView mEmpty = (ListView) mRootView.findViewById(R.id.studentsList);
StudentsAttendenceModel studentsAttendenceModel1=new StudentsAttendenceModel();
studentsAttendenceModel1.setStudentId("001");
studentsAttendenceModel1.setStudentRollNumber("1");
studentsAttendenceModel1.setStudentName("Anurag Thakur");
studentsAttendenceModel1.setStudentAttendenceStatus("Present");
studentsAttendenceModel1.setClassName("5th A");
mListInfo.add(studentsAttendenceModel1);
StudentsAttendenceModel studentsAttendenceModel2=new StudentsAttendenceModel();
studentsAttendenceModel2.setStudentId("002");
studentsAttendenceModel2.setStudentRollNumber("2");
studentsAttendenceModel2.setStudentName("Funsukh Wangadu");
studentsAttendenceModel2.setStudentAttendenceStatus("Present");
studentsAttendenceModel2.setClassName("5th A");
mListInfo.add(studentsAttendenceModel2);
StudentsAttendenceModel studentsAttendenceModel3=new StudentsAttendenceModel();
studentsAttendenceModel3.setStudentId("003");
studentsAttendenceModel3.setStudentRollNumber("3");
studentsAttendenceModel3.setStudentName("Chatur Lingam");
studentsAttendenceModel3.setStudentAttendenceStatus("Present");
studentsAttendenceModel3.setClassName("5th A");
mListInfo.add(studentsAttendenceModel3);
StudentsAttendenceModel studentsAttendenceModel4=new StudentsAttendenceModel();
studentsAttendenceModel4.setStudentId("004");
studentsAttendenceModel4.setStudentRollNumber("4");
studentsAttendenceModel4.setStudentName("Virusahastra Budhi");
studentsAttendenceModel4.setStudentAttendenceStatus("Present");
studentsAttendenceModel4.setClassName("5th A");
mListInfo.add(studentsAttendenceModel4);
mAttendanceAdapter = new StudentsAttendanceAdapter(mListInfo,this);
mListView.setAdapter(mAttendanceAdapter);
mListView.setSelectionFromTop(index, mTop);
//mListView.setEmptyView((TextView) mRootView.findViewById(R.id.studentName));
/*mAdapter = new ClassStudentsRecyclerAdapter(results,getContext());
mRecyclerView.setAdapter(mAdapter);*/
//swipeLayout.setOnRefreshListener(this);
SharedPreferenceSingleton.getInstance().init(getApplicationContext());
className = SharedPreferenceSingleton.getInstance().getStringPreference(TeacherPreference.CLASS_NAME);
SharedPreferenceSingleton.getInstance().init(getApplicationContext());
classIdNo = SharedPreferenceSingleton.getInstance().getStringPreference(SharedContracts.CLASS_LIST_INFO + className);
allStudentSelectionButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
String status=(String) v.getTag();
if (status=="Present")
{
allStudentSelectionButton.setText("Make All Late");
allStudentSelectionButton.setTag("Absent");
for (int i=0;i<mListInfo.size();i++)
{
mListInfo.get(i).setStudentAttendenceStatus("Absent");
}
}
else if (status=="Absent")
{
allStudentSelectionButton.setText("Make All Present");
allStudentSelectionButton.setTag("Late");
for (int i=0;i<mListInfo.size();i++)
{
mListInfo.get(i).setStudentAttendenceStatus("Late");
// ImageView attendanceStatus=(ImageView) mRootView.findViewById(R.id.attendenceStatusImage);
}
}
else if(status=="Late")
{
allStudentSelectionButton.setText("Make All Absent");
allStudentSelectionButton.setTag("Present");
for (int i=0;i<mListInfo.size();i++)
{
mListInfo.get(i).setStudentAttendenceStatus("Present");
// ImageView attendanceStatus=(ImageView) mRootView.findViewById(R.id.attendenceStatusImage);
}
}
mAttendanceAdapter.notifyDataSetChanged();
}
});
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
String status=mListInfo.get(position).getStudentAttendenceStatus();
if (status=="Present")
{
mListInfo.get(position).setStudentAttendenceStatus("Absent");
}
else if (status=="Absent")
{
mListInfo.get(position).setStudentAttendenceStatus("Late");
}
else if(status=="Late")
{
mListInfo.get(position).setStudentAttendenceStatus("Present");
}
mAttendanceAdapter.notifyDataSetChanged();
}
});
}
Ihr Adapter und Listenelement Layout erstellen. Verwenden Sie Checkboxen? –