Note that there are some explanatory texts on larger screens.

plurals
  1. POUnfortunately MyApplication has stopped
    text
    copied!<p>I am trying to start my activity from Listview items. it is working fine for first item but gives an error when I click on <code>SecondActivity</code>. Here is my code of <code>ListView</code> activity</p> <pre><code>public class menu extends ListActivity{ String [] menuItems = {"MainActivity","SecondActivity","Item2","Item3"}; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(menu.this,android.R.layout.simple_expandable_list_item_1, menuItems)); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); try { Log.d("Tst","Value"); Class menuItem = Class.forName("com.example.newboston." + menuItems[position] ); Intent itemItent = new Intent(menu.this, menuItem); startActivity(itemItent); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } </code></pre> <p>Here is Code of my <code>SecondActivity</code> </p> <pre><code>public class SecondActivity extends Activity{ EditText etPass = (EditText) findViewById(R.id.etPassword); Button btPass =(Button) findViewById(R.id.btPassword); ToggleButton tgPass = (ToggleButton) findViewById(R.id.tgPassword); TextView tvPass = (TextView) findViewById(R.id.displayTV); Random animate = new Random(); @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); // Log tag; // Log.d("testing", "In toggle java"); setContentView(R.layout.togglebtn); passTextCheck(); textPosition(); } public void passTextCheck(){ tgPass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if(tgPass.isChecked()){ etPass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); }else{ etPass.setInputType(InputType.TYPE_CLASS_TEXT); } } }); } public void textPosition(){ btPass.setOnClickListener(new View.OnClickListener() { // Toast testToast = new Toast(toggle.this); CharSequence text; @Override public void onClick(View v) { String check = tgPass.getText().toString(); if(check.contentEquals("left")){ tvPass.setGravity(Gravity.LEFT); tvPass.setTextColor(Color.BLUE); text = "Left + Blue"; Toast.makeText(SecondActivity.this, text ,Toast.LENGTH_SHORT).show(); }else if(check.contentEquals("right")){ tvPass.setGravity(Gravity.RIGHT); tvPass.setTextColor(Color.GREEN); text = "Right + Green"; Toast.makeText(SecondActivity.this, text ,Toast.LENGTH_SHORT).show(); }else if(check.contentEquals("center")){ tvPass.setGravity(Gravity.CENTER); tvPass.setTextColor(Color.MAGENTA); text = "Center + Magenta"; Toast.makeText(SecondActivity.this, text ,Toast.LENGTH_SHORT).show(); }else if(check.contentEquals("animate")){ tvPass.setText("Hello"); tvPass.setGravity(Gravity.CENTER); tvPass.setTextColor(Color.rgb(animate.nextInt(50), animate.nextInt(50),animate.nextInt(50)) ); } // TODO Auto-generated method stub } }); } } </code></pre> <p>Here is my <code>AndroidManifest.xml</code> code</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newboston" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.newboston.Startup" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.example.newboston.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="com.example.newboston.MAINACTIVITY" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.example.newboston.menu" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="com.example.newboston.menu" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.example.newboston.SecondActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="com.example.newboston.SecondActivity" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
 

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