Note that there are some explanatory texts on larger screens.

plurals
  1. POOnClick listview inside dialog fix
    primarykey
    data
    text
    <p>I cant seem to get this code to work at the moment.I would like to open a new activity with on click the list view I know this code is what am after but i have been playing about with this for days now and i just cant do it.</p> <pre><code> public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { switch( position ) { case 0: Intent newActivity = new Intent(this, superleague.class); startActivity(newActivity); break; case 1: Intent newActivity = new Intent(this, youtube.class); startActivity(newActivity); break; case 2: Intent newActivity = new Intent(this, olympiakos.class); startActivity(newActivity); break; case 3: Intent newActivity = new Intent(this, karaiskaki.class); startActivity(newActivity); break; case 4: Intent newActivity = new Intent(this, reservetickets.class); startActivity(newActivity); break; } } </code></pre> <p>main.java</p> <pre><code> import java.util.ArrayList; import android.app.Activity; import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void popUp(View v){ // Dummy list: ArrayList&lt;String&gt; dummies = new ArrayList&lt;String&gt;(); dummies.add("BMW"); dummies.add("FORD"); dummies.add("ROVER"); dummies.add("BMW"); dummies.add("FORD"); final Dialog dialog = new Dialog(MainActivity.this); dialog.setContentView(R.layout.customalertdialogdctivity); dialog.setTitle("List Title"); ListView listView = (ListView) dialog.findViewById(R.id.list); ArrayAdapter&lt;String&gt; ad = new ArrayAdapter&lt;String&gt;(this, R.layout.listrow , R.id.singleItem, dummies); listView.setAdapter(ad); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { //do something on click dialog.dismiss(); } }); dialog.show(); } } </code></pre> <p>main.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:onClick="popUp" android:text="pop dialog list" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Custom.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:divider="#b5b5b5" android:dividerHeight="1dp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>As i said if possible i would like to open a new activity when the list view is clicked. I have looked and tried but no luck hope someone can help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload