我在很多情况下都遇到了错误,并且能够通过SO的答案解决。但我没有找到错误的答案。请给我一个正确的方法来delcare并在下面的代码中定义函数..
谢谢你的推荐
package Cdis.Banglore.widget;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
public class WidgetActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(0,0,0, "Auto Complete");
menu.add(0,1,1, "Button");
menu.add(0,2,2, "CheckBox");
menu.add(0,3,3, "Edit Text");
menu.add(0,4,4, "RadioGroup");
menu.add(0,5,5, "Spinner=");
return true;
}
@Override
public boolean onOptionsItemSelected(Menu.Item item)
{
switch(item.getItemId())
{
case 0:
showAutoComplete();
return true;
case 1:
showButton();
return true;
case 2:
showCheckBox();
return true;
case 3:
editText();
return true;
case 4:
Rio();
return true;
case 5:
Spnr();
return true;
}
return true;
}
public void showAutoComplete()
{
Intent autocomplete = new Intent(this, autocomplete.class);
startActivity(autocomplete);
}
public void showButton()
{
Intent show = new Intent(this, testButton.class);
startActivity(show);
}
public void showCheckBox()
{
Intent box = new Intent(this, testButton.class);
startActivity(box);
}
public void editText()
{
Intent text = new Intent(this, editText.class);
startActivity(text);
}
public void Rio()
{
Intent rad = new Intent(this, Radio.class);
startActivity(rad);
}
public void Spnr()
{
Intent spr = new Intent(this, Spinn.class);
startActivity(spr);
}
}