Android list view setOnItemClickListener not working

前端 未结 4 859
执念已碎
执念已碎 2021-01-13 06:04

I want to hide the edit text and button field initially in list view and show that edit text and button for a particular raw in list view when that raw is clicked.So I tried

4条回答
  •  隐瞒了意图╮
    2021-01-13 06:26

    // try this
    public class MainPortal extends Activity {
        private List employees = new ArrayList();
        EditText et;
        ListView list;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main_portal);
            populateEmployeeList();
            //populsteListView();
    
            list = (ListView) findViewById(R.id.employeeListView);
            ArrayAdapter adapter = new MylistAdapter();
            list.setAdapter(adapter);
    
            list.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView parent, View view,
                                        int position, long id) {
    //I ADDED ON CLICK IMPLEMENTATION HERE, BUT THIS IS NOT WORKING
                    Toast.makeText(getApplicationContext(), "CLICKED", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
    

提交回复
热议问题