I used ABS 4.0 with two MenuItems in one of my applications, but found a small error: when I press the second MenuItem, it does the same as the first ...
I tried everything that I can think of, but it does not work. I changed onOptionItemSelected as I thought this was the method I needed to change.
EDIT:
I watched @Ollie's suggestions, but neither LogCat nor Debug show strange things. Maybe this is in some other part of the code or declaration for ABS? Here's the whole code, if you could view it, it would be great!
Code for all activities, how could it be in any other place?
package bas.sie.Antonius; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; public class TeacherInfo extends SherlockActivity { String URLhome; String Info; String TeacherAb; TextView mTxtvInfo; Button mBtnTeacherStSchedule; Button mBtnTeacherDaySchedule; private static String mainUrl = "http://www.carmelcollegegouda.nl/site_ant/"; private static String endUrl = ".htm"; private static String[] myUrls = { "roosters/dagroosters/Doc_V1_", "roosters/standaardroosters/Doc1_" }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.contactinfo); setTitle("Over deze leraar"); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mTxtvInfo = (TextView) findViewById(R.id.TxtvTeacher); Intent startingIntent = getIntent(); Info = startingIntent.getStringExtra("contact"); mTxtvInfo.setText(Info); Intent startingIntent1 = getIntent(); TeacherAb = startingIntent1.getStringExtra("abbrev"); mBtnTeacherDaySchedule = (Button) findViewById(R.id.btnTeacherDaySchedule); mBtnTeacherStSchedule = (Button) findViewById(R.id.btnTeacherStSchedule); mBtnTeacherDaySchedule.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { URLhome = makeUrl(0); Intent i = new Intent(TeacherInfo.this, MyWebView.class); i.putExtra("home", URLhome); startActivityForResult(i, 0); } }); mBtnTeacherStSchedule.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { URLhome = makeUrl(1); Intent i = new Intent(TeacherInfo.this, MyWebView.class); i.putExtra("home", URLhome); startActivityForResult(i, 0); } }); } private String makeUrl(int index) { String s = mainUrl + myUrls[index] + TeacherAb + endUrl; return s; }
I think the problem is declaring menu items, but I don't see any problem there ...
Could you take a look at my menu.xml? Posted here:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/settings" android:icon="@drawable/ic_settings" android:title="Instellingen"></item> <item android:id="@+id/about" android:icon="@drawable/ic_about" android:title="Over de app"></item> </menu>
source share