public void onItemClick(AdapterView<?> a, View v, int position, long id) { AlertDialog.Builder adb = new AlertDialog.Builder(CategoriesTab.this); adb.setTitle("Selected Category"); adb.setMessage("Selected Item is = "+lv1.getItemAtPosition(position)); adb.setPositiveButton("Ok", null); adb.show(); }
This at the moment displays an alertbox when an item from listview is clicked. I want to convert the alertbox to load a specific xml for each choices clicked. How can i do this? thanks for your help.
Kotlin does not provide an option to write a switch-case statement; however we can implement the switch-case functionality in Kotlin using the when() function which works exactly the same way switch works in other programming languages.
The switch case in java is used to select one of many code blocks for execution. Break keyword: As java reaches a break keyword, the control breaks out of the switch block. The execution of code stops on encountering this keyword, and the case testing inside the block ends as the match is found.
Yes. When the code enters a case block, it'll continue executing all commands until it reaches the break or say a return statement.
switch(position) { case 0: setContentView(R.layout.xml0); break; case 1: setContentView(R.layout.xml1); break; default: setContentView(R.layout.default); break; }
i hope this will do the job!
@Override public void onClick(View v) { switch (v.getId()) { case R.id.: break; case R.id.: break; default: break; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With