ここでアプリを起動します:
http://developer.android.com/training/basics/firstapp/index.html
チュートリアルから直接コピーすると、エラーがいっぱいです。コピペしても。作業ファイルを表示して、何か問題があるかどうかを確認できるリポジトリはありますか?
たとえば、MainActivity.java では次のようになります。
package com.example.my.first.app;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
/** Called when the user clicks the Send button */
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
しかし、それは返します:
10 行目の「View を型に解決できません」 11 行目の「この行にある複数のマーカー: Intent を型に解決できません」 12 行目の「この行にある複数のマーカー: EditText を型に解決できません」
次に DisplayMessageActivity.java で:
package com.example.my.first.app;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
public class DisplayMessageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
}
そしてそれは戻ります:
12 行目の「インテントをタイプに解決できません」 16 行目の「この行に複数のマーカー: TextView をタイプに解決できません」
これは私の最初のアプリであり、公式のチュートリアルに従えば問題ないと思いましたが、機能していません。私は最新の Eclipse と Andorid SDK を使用しています (実際のところ、今夜ダウンロードしました)。