Android의 목록보기 항목에서 0 번째 위치를 제거하고 싶습니다. 나는 SQLite database.But에서 목록보기를 채우기 위해 onCreate() 메서드의 목록보기에서 0 번째 위치 항목을 제거하려고합니다. 어떻게 해야할지 모르겠다. 나는 시도했지만 내 응용 프로그램이 충돌하고 예외 ArrayIndexOutOfBoundException Invallid 인덱스 3, 크기입니다 3. 어떤 사람이 이것을 수행하는 방법을 정렬하는 데 도움이 될 수 있습니다. 감사합니다.안드로이드에서 목록보기 항목을 제거 하시겠습니까?
내 어댑터 클래스 코드는 다음과 같습니다.
public class EmployeeList_Adapter extends BaseAdapter
{
Context context;
ArrayList<Employee> Employee_List;
protected SQLiteDatabase db;
public EmployeeList_Adapter(Context context,
ArrayList<Employee> employee_List) {
super();
this.context = context;
Employee_List = employee_List;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return Employee_List.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return Employee_List.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup arg2) {
// TODO Auto-generated method stub
Employee EmployeeListItems = Employee_List.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.staff_employee_list_item, null);
}
TextView tvID = (TextView) convertView.findViewById(R.id.textViewStaff_emp_Id);
tvID.setText(EmployeeListItems.getEmployeeId()+"");
ImageView imgProfile = (ImageView) convertView.findViewById(R.id.imgStaff_Emp);
TextView tvName = (TextView) convertView.findViewById(R.id.textViewStaff_Emp_ame);
tvName.setText(EmployeeListItems.getName());
TextView tvDepartment = (TextView) convertView.findViewById(R.id.textViewStaff_Emp_Department);
tvDepartment.setText(EmployeeListItems.getDepartment());
TextView tvDesignation = (TextView) convertView.findViewById(R.id.textViewStaff_Emp_Designation);
tvDesignation.setText(EmployeeListItems.getDesignation());
TextView tvPerformanceDate = (TextView) convertView.findViewById(R.id.textDate);
tvPerformanceDate.setText(EmployeeListItems.getDate());
TextView tvPerformanceRate = (TextView) convertView.findViewById(R.id.empLoyeeRate);
tvPerformanceRate.setText(EmployeeListItems.getPerformancerate());
final Employee empPOsition = Employee_List.get(position);
int positionA = Employee_List.indexOf(empPOsition);
notifyDataSetChanged();
System.out.println(" empPOsition = " + positionA);
if(positionA == 0)
{
Employee_List.remove(position);
}
return convertView;
}
}
Here is my Log Cat Error
07-15 11:41:56.322: E/AndroidRuntime(651): FATAL EXCEPTION: main
07-15 11:41:56.322: E/AndroidRuntime(651): java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3
07-15 11:41:56.322: E/AndroidRuntime(651): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
07-15 11:41:56.322: E/AndroidRuntime(651): at java.util.ArrayList.get(ArrayList.java:311)
07-15 11:41:56.322: E/AndroidRuntime(651): at com.sqlitedemo.EmployeeList_Adapter.getView(EmployeeList_Adapter.java:49)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.ListView.makeAndAddView(ListView.java:1745)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.ListView.fillDown(ListView.java:670)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.ListView.fillFromTop(ListView.java:727)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.ListView.layoutChildren(ListView.java:1598)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.view.View.layout(View.java:7175)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.view.View.layout(View.java:7175)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.view.View.layout(View.java:7175)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.view.View.layout(View.java:7175)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.os.Handler.dispatchMessage(Handler.java:99)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.os.Looper.loop(Looper.java:123)
07-15 11:41:56.322: E/AndroidRuntime(651): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-15 11:41:56.322: E/AndroidRuntime(651): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 11:41:56.322: E/AndroidRuntime(651): at java.lang.reflect.Method.invoke(Method.java:507)
07-15 11:41:56.322: E/AndroidRuntime(651): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-15 11:41:56.322: E/AndroidRuntime(651): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-15 11:41:56.322: E/AndroidRuntime(651): at dalvik.system.NativeStart.main(Native Method)