このコードにはエラーは含まれていませんが、実行すると「残念ながら停止しました」と表示されます。コードは、数の因数を見つけるためのものです。私はそれが簡単であることを知っていますが、私はアンドロイド技術に慣れていないので、助けが必要です.
public class MainActivity extends Activity {
EditText edttxt;
Button btn;
int i=0 ;
String str;
TextView textview1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edttxt=(EditText)findViewById(R.id.editText1);
btn=(Button)findViewById(R.id.button1);
textview1=(TextView)findViewById(R.id.textView1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
ArrayList<Integer> a=new ArrayList<Integer>();
i=Integer.parseInt(edttxt.getText().toString());
if(i==0)
{
Toast.makeText(getBaseContext(), "invalid",Toast.LENGTH_SHORT).show();
}
else
{
for(int j=2;j<(i/2);j++)
{
if(i%j==0)
{
a.add(j);
}
}
int arraylistSize = a.size();
for(int i = 0; i < arraylistSize; i++) {
textview1.setText(a.get(i));
textview1.setText("*");
}
}
}
}
);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
logcat は次のとおりです。
08-14 21:13:31.381: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:31.381: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:32.051: W/Resources(793): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f080002}
08-14 21:13:32.281: W/Resources(793): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f080003}
08-14 21:13:32.291: W/Resources(793): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f080005}
08-14 21:13:32.492: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:32.492: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:32.711: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:32.821: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:32.951: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:32.951: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.021: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.232: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.232: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.281: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.281: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.291: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.302: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.321: D/gralloc_goldfish(793): Emulator without GPU emulation detected.
08-14 21:13:33.581: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.681: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.691: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:33.691: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.011: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.011: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.192: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.192: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.301: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.301: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.701: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.701: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.765: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:34.771: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:35.293: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:35.293: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:35.373: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:35.373: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:35.731: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:35.731: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.063: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.063: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.281: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.322: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.452: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.461: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.882: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.941: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:36.992: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.021: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.341: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.351: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.401: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.401: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.971: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:37.981: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:38.061: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:38.061: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:38.461: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:38.461: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:38.521: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:38.521: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.081: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.081: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.181: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.181: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.521: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.521: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.641: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:39.651: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.101: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.101: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.181: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.181: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.653: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.653: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.691: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:40.721: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:41.158: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:41.161: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:41.201: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:41.236: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:41.716: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:41.761: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.101: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.101: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.171: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.211: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.481: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.481: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.713: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.713: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.851: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:42.851: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.181: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.181: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.371: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.371: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.441: D/dalvikvm(793): GC_CONCURRENT freed 102K, 8% free 2670K/2892K, paused 59ms+90ms, total 759ms
08-14 21:13:43.776: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.776: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.801: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:43.801: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:44.321: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:44.332: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:44.441: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:44.441: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:44.772: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:44.792: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.225: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.225: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.284: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.284: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.714: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.714: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.851: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:45.851: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.141: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.141: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.311: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.311: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.791: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.791: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.821: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:46.821: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.301: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.301: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.331: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.331: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.641: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.641: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.881: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.881: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.951: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:47.951: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.372: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.372: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.512: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.512: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.872: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.872: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.903: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0
08-14 21:13:48.921: W/Trace(793): Unexpected value from nativeGetEnabledTags: 0