0
public class MainActivity extends Activity implements OnClickListener, AdapterView.OnItemSelectedListener, OnCheckedChangeListener{

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);

    //Declare Variables to be used
    final Bundle bundle = new Bundle();
    final CheckBox checkbox01 = (CheckBox) findViewById(R.id.CheckBox01);


    //All if statements for builds
    final Button findbuilds = (Button) findViewById(R.id.btn_FindBuildsTab1);{
        findbuilds.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                 if ((v==findbuilds)&&(checkbox01.getText()==("Ahri-AP"))&&((checkbox01).isChecked())){
                     final String charactername = "Ahri-AP";
                 }
                 if ((checkbox01).isChecked(){
                   //All Bundles are placed here
                     bundle.putString("CharacterName Value Key", charactername);

                   //Start Tabhost Activity and pass bundle(s)
                     Intent nextActivity = new Intent(v.getContext(),
                     nextActivity.putExtras(bundle);
                     startActivity(nextActivity); TabHostActivity.class);
                 }

基本上,我要做的是在第一个 if 语句中为角色名称创建字符串,然后将其捆绑在另一个 if 语句中。我需要将字符串捆绑在不同的 if 语句中的原因是为了避免达到方法的字节限制。我总共需要为每个 if 语句捆绑 64 个不同的字符串,并且我总共需要发生 126 个 if 语句。问题当然是在第二个 if 语句中的捆绑包中永远找不到或解决 String 变量。有没有办法做到这一点?或者也许是更有效的方法?在此先感谢您的帮助!:)

4

1 回答 1

0

只需将变量的定义拉到 if 语句之外。例如:

final String charactername 
if() {
    charactername = ...
}
if() {
    bundle stuff with charactername 
}
于 2012-06-05T17:26:20.113 回答