1

私はアプリを開発しました..それは数秘術アプリです..ユーザーのファーストネーム、セカンドネーム、サードネームが収集され、計算されます.1〜9の値が各値に割り当てられ、すべての文字のこれらの値を計算するときは一緒に追加して1桁の1〜9にします。その後、この値は別のアクティビティのテキストビューに与えられ、結果が表示されます....私の問題は、プログラミングを行ったことです..しかし、追加すると..正しい値ではありません表示..各文字の値を指定するためにスイッチケースを使用しました...デフォルト値として 0 を指定しました..結果が表示されると、値は 0 として表示されます。私がそれを1に変更すると、値に1が追加され、その値が再生されます..コードを確認してください.間違いがあれば指摘してください.4私...ありがとう...

MainActivity.java

public void gReport(View V)
{
long sum1 = 0;
long sum2 = 0;
long sum3 = 0;
long sum7 = 0;
long sum8 = 0;
long sum9 = 0;
long sum10 = 0;
EditText et1 = (EditText) findViewById (R.id.editText1);
EditText et2 = (EditText) findViewById (R.id.editText2);
EditText et3 = (EditText) findViewById (R.id.editText3);

EditText et7 = (EditText) findViewById (R.id.editText7);
EditText et8 = (EditText) findViewById (R.id.editText8);
EditText et9 = (EditText) findViewById (R.id.editText9);

sum1 = getSum1(et1.getText().toString());
sum2 = getSum2(et2.getText().toString());
sum3 = getSum3(et3.getText().toString());

/*sum7 = getSum7(et7.getText().toString());
sum8 = getSum8(et8.getText().toString());
sum9 = getSum9(et9.getText().toString());*/



sum10 = getSum10 (et1.getText().toString() + et2.getText().toString() + et3.getText().toString());  
Intent i = new Intent(this, FirstResult.class);
i.putExtra("name10", sum10 + "");
startActivity(i);
}

private long getSum10(String text)  
{
long sum10 = 0;
char[] name10 = new char[text.length()];
name10 = text.toCharArray();

for(int i=0; i<text.length(); i++)
{
     sum10 += value10( name10[i] );
}
while (sum10>9)
{                    
      sum10 = findDigitSum10(sum10);
}
  return sum10;         
}
private long value10(char a) 
{
        switch(a)
            {
               case 'A': 
               return 1;    
               case 'B':
               return 2;
               case 'C':
               return 3;
               case 'D':
               return 4;
               case 'E':
               return 5;
               case 'F':
               return 6;
               case 'G':
               return 7;
               case 'H':
               return 8;
               case 'I':
               return 9;
               case 'J':
               return 1;
               case 'K':
               return 2;
               case 'L':
               return 3;
               case 'M':
               return 4;
               case 'N':
               return 5;
               case 'O':
               return 6;
               case 'P':
               return 7;
               case 'Q':
               return 8;
               case 'R':
               return 9;
               case 'S':
               return 1;          
               case 'T':
               return 2;
               case 'U':
               return 3;
               case 'V':
               return 4;
               case 'W':
               return 5;
               case 'X':
               return 6;
               case 'Y':
               return 7;
               case 'Z':
               return 8;
               default:         
               return 0;
            }       
        }

 private long findDigitSum10(long n)        
 {

  int sum10=0;
        while (n != 0)
            {
             sum10 += n % 10;
             n = n / 10;
            }

           return sum10;

}
}

結果アクティビティ.java

@Override
    protected void onCreate(Bundle savedInstanceState) 

    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.firstresult_xm);


        TextView txt1 = (TextView) findViewById (R.id.textView2);
        txt1.setText(getIntent().getStringExtra("name10"));


    }
4

2 に答える 2

5

sum10の中にキーはありませんintentが、 だけname10です。String int が最初TextViewに表示され、2 番目の int には何も表示されないはずです

于 2013-11-05T09:20:27.733 に答える