-1

アプリを開発しようとしていますが、エミュレーターで起動できません。ここにこのコードブロックがあります

import java.util.ArrayList;
import java.util.List;


import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;



public abstract class Calculator extends Activity
  implements SeekBar.OnSeekBarChangeListener
{
  private static final int SHOW_RECOMMEND_APP_MSG_ID = 65545;
  InputMethodManager adManager;

  ImageButton addButton;
  CompoundButton.OnCheckedChangeListener boxListener = new CompoundButton.OnCheckedChangeListener()
  {
    public void onCheckedChanged(CompoundButton paramCompoundButton, boolean paramBoolean)
    {
      Calculator.this.setResult();
    }
  };
  View.OnClickListener buttonListener = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      Object localObject;
      switch (paramView.getId())
      {
      case 2131165186:
        localObject = new Intent(Calculator.this, inputarea.class);
        ((Intent)localObject).putExtra("INT", false);
        Calculator.this.startActivityForResult((Intent)localObject, 152);
        break;
      case 2131165189:
        Calculator.this.percentSeekBar.setProgress(Calculator.this.percentValue - setting.getButton1(Calculator.this));
        break;
      case 2131165190:
        Calculator.this.percentSeekBar.setProgress(Calculator.this.percentValue - setting.getButton2(Calculator.this));
        break;
      case 2131165191:
        Calculator.this.percentSeekBar.setProgress(Calculator.this.percentValue + setting.getButton3(Calculator.this));
        break;
      case 2131165192:
        Calculator.this.percentSeekBar.setProgress(Calculator.this.percentValue + setting.getButton4(Calculator.this));
        break;
      case 2131165201:
        localObject = new Intent(Calculator.this, inputarea.class);
        ((Intent)localObject).putExtra("INT", false);
        Calculator.this.startActivityForResult((Intent)localObject, 153);
        break;
      case 2131165202:
        if (Calculator.this.totalValue != 0.0F)
        {
          Calculator.this.setResult();
          if (Utils.getSDKVersionNumber() <= 3)
            break;
          Calculator.this.setAnimation();
        }
        else
        {
          Calculator.this.shake = AnimationUtils.loadAnimation(Calculator.this, 2130968578);
          Calculator.this.totalValueButton.startAnimation(Calculator.this.shake);
          Toast.makeText(Calculator.this, 2131034139, 0).show();
        }
        break;
      case 2131165203:
        Calculator.this.resetView();
        break;
      case 2131165204:
        Calculator.this.listPrice.add(Float.valueOf(Calculator.this.resultValue));
        Calculator.this.listDiscount.add(Integer.valueOf(Calculator.this.percentValue));
        Calculator.this.listOriginPrice.add(Float.valueOf(Calculator.this.totalValue));
        Calculator.this.listSaved.add(Float.valueOf(Calculator.this.savedValue));
        localObject = Calculator.this;
        ((Calculator)localObject).totalPriceValue += Calculator.this.resultValue;
        localObject = Calculator.this;
        ((Calculator)localObject).totalSavedValue += Calculator.this.savedValue;
        Calculator.this.setTotalText();
        if (!Calculator.this.taxBox.isChecked())
          Calculator.this.listTax.add(Float.valueOf(Float.parseFloat("0")));
        else
          Calculator.this.listTax.add(Float.valueOf(setting.getConfigTax(Calculator.this)));
        Calculator.this.setListStatus();
        Calculator.this.priceList.setOnItemClickListener(new AdapterView.OnItemClickListener()
        {
          private Builder setPositiveButton;

        public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
          {
            Utils.l(paramInt + " was click");
            AlertDialog.Builder localBuilder = new AlertDialog.Builder(Calculator.this);
            localBuilder.setMessage(2131034150);
            setPositiveButton = localBuilder.setPositiveButton(Calculator.this.getString(2131034151), new DialogInterface.OnClickListener()
            {
              private int val$location;

            public void onClick(DialogInterface paramDialogInterface, int paramInt)
              {
                Calculator.this.removeItemFromList(this.val$location);
                Calculator.this.setTotalText();
                Calculator.this.setListStatus();
              }
            });
            localBuilder.setNegativeButton(Calculator.this.getString(2131034152), new DialogInterface.OnClickListener()
            {
              public void onClick(DialogInterface paramDialogInterface, int paramInt)
              {
              }
            });
            localBuilder.show();
          }
        });
      case 2131165187:
      case 2131165188:
      case 2131165193:
      case 2131165194:
      case 2131165195:
      case 2131165196:
      case 2131165197:
      case 2131165198:
      case 2131165199:
      case 2131165200:
      }
    }
  };
  Button calculateButton;
  Button clearButton;
  Context context;
  String ePercentString;
  Button firstButton;
  Button forthButton;
  private InfolifeEventListener infolifeEventListener = new InfolifeEventListener()
  {
    public void hasUpdate(JSONObject paramJSONObject)
    {
      Calculator.this.mHandler.obtainMessage(257).sendToTarget();
    }

    public void noUpdateNotification()
    {
      Calculator.this.mHandler.obtainMessage(259).sendToTarget();
    }

    public void onFetchedData(JSONObject paramJSONObject)
    {
      Message localMessage = Calculator.this.mHandler.obtainMessage(258);
      localMessage.obj = paramJSONObject;
      localMessage.sendToTarget();
    }



  private void checkUpdate()
  {
    boolean bool = true;
    if ((setting.getAutoUpdateStat(this)) && (Constants.market.shouldCheckUpdate()))
      bool = true;
    this.mChecker = new VersionChecker(this, this.infolifeEventListener, false);
    this.mChecker.checkUpdateinThread(bool, Constants.market.shouldShowRecommendApps());
    Utils.l("finish check :" + bool + "," + Constants.market.shouldShowRecommendApps());
  }

  private void removeItemFromList(int paramInt)
  {
    this.totalPriceValue = 0.0F;
    this.totalSavedValue = 0.0F;
    this.listPrice.remove(paramInt);
    this.listDiscount.remove(paramInt);
    this.listOriginPrice.remove(paramInt);
    this.listSaved.remove(paramInt);
    if (this.listPrice.size() == 0)
    {
      Utils.l("size=0");
      this.priceList.setVisibility(8);
      this.totalPriceLayout.setVisibility(8);
      this.totalSavedLayout.setVisibility(8);
    }
    for (int i = 0; i <= -1 + this.listPrice.size(); i++)
    {
      this.totalPriceValue += ((Float)this.listPrice.get(i)).floatValue();
      this.totalSavedValue += ((Float)this.listSaved.get(i)).floatValue();
    }
  }

  private void resetView()
  {
    this.percentSeekBar.setProgress(0);
    this.totalValueButton.setText(2131034123);
    this.totalValue = 0.0F;
    this.resultText.setText(2131034125);
    this.totalValueButton.requestFocus();
    this.totalPriceLayout.setVisibility(8);
    this.totalSavedLayout.setVisibility(8);
    this.priceList.setVisibility(8);
    this.listPrice.clear();
    this.listDiscount.clear();
    this.listOriginPrice.clear();
    this.listTax.clear();
    this.totalPriceValue = 0.0F;
    this.totalSavedValue = 0.0F;
    this.adapter = new priceListAdapter(this, this.listPrice, this.listOriginPrice, this.listDiscount, this.listTax);
    this.priceList.setAdapter(this.adapter);
  }

  private void setListStatus()
  {
    LinearLayout.LayoutParams localLayoutParams = (LinearLayout.LayoutParams)this.priceList.getLayoutParams();
    this.listHeight = (3 + Utils.dip2px(this));
    localLayoutParams.height = (this.listHeight * this.listOriginPrice.size());
    this.priceList.setLayoutParams(localLayoutParams);
    this.adapter = new priceListAdapter(this, this.listPrice, this.listOriginPrice, this.listDiscount, this.listTax);
    this.priceList.setAdapter(this.adapter);
  }

  private void setTotalText()
  {
    if (this.listSaved.size() != 0)
    {
      this.priceList.setVisibility(0);
      this.totalPriceLayout.setVisibility(0);
      this.totalSavedLayout.setVisibility(0);
    }
    this.totalPriceText.setText(Utils.currencyFormater.format(this.totalPriceValue));
    this.totalSavedText.setText(Utils.currencyFormater.format(this.totalSavedValue));
  }

  private void showDonateDialog()
  {
    new AlertDialog.Builder(this).setIcon(17301576).setTitle(2131034158).setMessage(2131034159).setPositiveButton(2131034160, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        Utils.openDonateApp(Calculator.this);
      }
    }).setNegativeButton(2131034161, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        Utils.gotoMarket(Calculator.this);
      }
    }).show();
  }

  private void showFeaturedDialog()
  {
    new AlertDialog.Builder(this).setTitle(2131034165).setMessage(2131034166).setPositiveButton(2131034156, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        Intent localIntent = new Intent(Calculator.this, FeaturedAppsActivity.class);
        Calculator.this.startActivity(localIntent);
      }
    }).setNegativeButton(2131034157, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
      }
    }).show();
  }


  private void showRecommendDialog()
  {
    new AlertDialog.Builder(this).setIcon(2130837510).setTitle(2131034154).setMessage(2131034155).setPositiveButton(2131034156, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        Utils.openRecommendApp(Calculator.this);
      }
    }).setNegativeButton(2131034157, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
      }
    }).show();
  }

  private void showUpdateDialog(String paramString)
  {
    new AlertDialog.Builder(this).setMessage(paramString).setPositiveButton(2131034148, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        Utils.gotoMarket(Calculator.this);
      }
    }).setNegativeButton(2131034149, new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
      }
    }).show();
  }

  public void cleanList()
  {
    this.listPrice.clear();
    this.listDiscount.clear();
    this.listOriginPrice.clear();
    this.listSaved.clear();
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    if (paramIntent != null)
    {
      if ((paramInt1 == 152) && (paramInt2 == 100))
      {
        this.totalValue = Float.parseFloat(paramIntent.getStringExtra("value").toString());
        this.totalValueButton.setText(Utils.currencyFormater.format(this.totalValue));
        setResult();
      }
      if ((paramInt1 == 153) && (paramInt2 == 100))
      {
        this.taxValue = Float.parseFloat(paramIntent.getStringExtra("value").toString());
        this.taxValueButton.setText(Utils.floatFormater.format(this.taxValue));
        setting.setConfigTax(this.taxValue, this);
        setResult();
      }
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    Utils.l("on creat");
    setContentView(2130903040);
    this.context = this;
    setView();
    this.mStatusChecker = new DataCollector(this, true);
    checkUpdate();
    int i = setting.getOpenRecommendStat(this);
    if ((i != 2) && (i != 4) && (i == 5))
      showFeaturedDialog();
    setting.setOpenRecommedTime(this, i + 1);
    this.listTax = new ArrayList();
    this.listPrice = new ArrayList();
    this.listOriginPrice = new ArrayList();
    this.listSaved = new ArrayList();
    this.listDiscount = new ArrayList();
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    super.onCreateOptionsMenu(paramMenu);
    paramMenu.add(2, 1, 5, getString(2131034131)).setIcon(17301568);
    paramMenu.add(2, 2, 1, getString(2131034130)).setIcon(17301566);
    paramMenu.add(4, 3, 6, getString(2131034129)).setIcon(17301569);
    paramMenu.add(2, 5, 0, getString(2131034133)).setIcon(17301577);
    paramMenu.add(3, 6, 4, getString(2131034153)).setIcon(17301586);
    paramMenu.add(3, 7, 3, getString(2131034158)).setIcon(17301576);
    paramMenu.add(1, 8, 2, getString(2131034164)).setIcon(17301619);
    return true;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    case 1:
      new AlertDialog.Builder(this).setTitle(2131034131).setMessage(2131034138).setPositiveButton(2131034118, new DialogInterface.OnClickListener()
      {
        public void onClick(DialogInterface paramDialogInterface, int paramInt)
        {
        }
      }).setNegativeButton(2131034134, new DialogInterface.OnClickListener()
      {
        public void onClick(DialogInterface paramDialogInterface, int paramInt)
        {
          Intent localIntent = new Intent("android.intent.action.SEND");
          localIntent.putExtra("android.intent.extra.SUBJECT", Calculator.this.getString(2131034136));
          localIntent.putExtra("android.intent.extra.TEXT", Calculator.this.getString(2131034137) + "http://market.android.com/search?q=pname:" + Calculator.this.getPackageName());
          localIntent.setType("text/plain");
          Calculator.this.startActivity(localIntent);
        }
      }).show();
      break;
    case 2:
      Intent localIntent = new Intent("android.intent.action.SENDTO");
      localIntent.setData(Uri.parse("mailto:mars@infolife.mobi"));
      localIntent.putExtra("android.intent.extra.SUBJECT", getString(2131034112) + " Feedback");
      startActivity(localIntent);
      break;
    case 3:
      new AlertDialog.Builder(this).setTitle(2131034129).setMessage(2131034135).setPositiveButton(2131034118, new DialogInterface.OnClickListener()
      {
        public void onClick(DialogInterface paramDialogInterface, int paramInt)
        {
        }
      }).show();
      break;
    case 5:
      startActivity(new Intent(this, setting.class));
      break;
    case 6:
      startActivity(new Intent(this, FeaturedAppsActivity.class));
      break;
    case 7:
      showDonateDialog();
      break;

    case 4:
    }
    return super.onOptionsItemSelected(paramMenuItem);
  }

  public void onPause()
  {
    super.onPause();
    Utils.l("on pause");
    Data.onPause(this);
  }

  public void onProgressChanged(SeekBar paramSeekBar, int paramInt, boolean paramBoolean)
  {
    if (paramSeekBar.getId() == 2131165188)
    {
      this.percentText.setText("  " + paramInt + "% OFF");
      this.percentValue = paramInt;
    }
    setResult();
  }

  public void onResume()
  {
    super.onResume();
    Utils.l("on resume");
    Data.onResume(this);
    setButtonText();
  }

  public void onStartTrackingTouch(SeekBar paramSeekBar)
  {
  }

  public void onStopTrackingTouch(SeekBar paramSeekBar)
  {
  }

  void setAnimation()
  {
    View localView = findViewById(2131165184);
    TranslateAnimation localTranslateAnimation = new TranslateAnimation(localView.getWidth(), 0.0F, 0.0F, 0.0F);
    localTranslateAnimation.setDuration(1200L);
    localTranslateAnimation.setInterpolator(AnimationUtils.loadInterpolator(this, 17432586));
    localTranslateAnimation.setStartOffset(200L);
    localView.startAnimation(localTranslateAnimation);
  }

  void setButtonText()
  {
    this.firstButton.setText("-" + setting.getButton1(this) + "%");
    this.secondButton.setText("-" + setting.getButton2(this) + "%");
    this.thirdButton.setText("+" + setting.getButton3(this) + "%");
    this.forthButton.setText("+" + setting.getButton4(this) + "%");
  }

  void setResult()
  {
    boolean bool = false;
    this.resultValue = (this.totalValue * (100 - this.percentValue) / 100.0F);
    this.savedValue = (this.totalValue - this.resultValue);
    if (this.taxBox.isChecked())
    {
      bool = true;
      this.taxValue = Float.parseFloat(this.taxValueButton.getText().toString());
      this.resultValue += this.resultValue * this.taxValue / 100.0F;
      this.savedValue += this.totalValue * this.taxValue / 100.0F * this.percentValue / 100.0F;
    }
    setting.setTaxStat(Boolean.valueOf(bool), this.context);
    this.savedText.setText(getString(2131034124) + " " + Utils.currencyFormater.format(this.savedValue));
    this.resultText.setText(Utils.currencyFormater.format(this.resultValue));
  }

  void setView()
  {
    this.totalPriceLayout = ((LinearLayout)findViewById(2131165209));
    this.totalSavedLayout = ((LinearLayout)findViewById(2131165207));
    this.percentSeekBar = ((SeekBar)findViewById(2131165188));
    this.percentText = ((TextView)findViewById(2131165187));
    this.resultText = ((TextView)findViewById(2131165184));
    this.savedText = ((TextView)findViewById(2131165185));
    this.totalPriceText = ((TextView)findViewById(2131165210));
    this.totalSavedText = ((TextView)findViewById(2131165208));
    this.taxBox = ((CheckBox)findViewById(2131165200));
    this.totalValueButton = ((Button)findViewById(2131165186));
    this.taxValueButton = ((Button)findViewById(2131165201));
    this.firstButton = ((Button)findViewById(2131165189));
    this.secondButton = ((Button)findViewById(2131165190));
    this.thirdButton = ((Button)findViewById(2131165191));
    this.forthButton = ((Button)findViewById(2131165192));
    this.priceList = ((ListView)findViewById(2131165206));
    this.clearButton = ((Button)findViewById(2131165203));
    this.calculateButton = ((Button)findViewById(2131165202));
    this.addButton = ((ImageButton)findViewById(2131165204));
    this.resultText.setFocusable(true);
    this.resultText.setFocusableInTouchMode(true);
    this.totalValueButton.setFocusable(true);
    this.taxBox.setChecked(setting.getTaxStat(this.context));
    this.taxBox.setOnCheckedChangeListener(this.boxListener);
    this.taxValueButton.setText(String.valueOf(setting.getConfigTax(this)));
    this.taxBox.setText(2131034122);
    this.percentSeekBar.setOnSeekBarChangeListener(this);
    this.firstButton.setOnClickListener(this.buttonListener);
    this.secondButton.setOnClickListener(this.buttonListener);
    this.thirdButton.setOnClickListener(this.buttonListener);
    this.forthButton.setOnClickListener(this.buttonListener);
    this.totalValueButton.setOnClickListener(this.buttonListener);
    this.taxValueButton.setOnClickListener(this.buttonListener);
    this.clearButton.setOnClickListener(this.buttonListener);
    this.calculateButton.setOnClickListener(this.buttonListener);
    if (this.addButton != null)
      this.addButton.setOnClickListener(this.buttonListener);
    setButtonText();
  }
  }

ブロックの最後にエラーがあります

Multiple markers at this line
    - Syntax error, insert "}" to complete 
     ClassBody
    - Syntax error, insert ";" to complete 
     FieldDeclaration
    - Syntax error, insert ";" to complete 
     FieldDeclaration

これを解決する方法はありますか?私は探していて、何も見つかりませんでした。

ありがとうございました。

4

2 に答える 2

2

うわー、なぜ findViewById でハードコードされた数字を使用しているのですか? R.id.buttonName などを使用する必要があります。そうでなければ、それらは常に台無しになります。ほとんどすぐに変更する必要があること、または今後問題が発生することはありません。

于 2012-07-26T21:23:02.043 に答える
1

追加; 最後の}の後に、下部の新しい行に}を追加します。これでエラーが解決するはずです

于 2012-07-26T21:44:08.760 に答える