別のリンクを開くいくつかのボタンを作成しようとしていますが、ファイルをコピーすると、onCreate(Bundle) が既に定義されているというエラーが表示されますか? 2つ持っているからprotected void onCreate(Bundle savedInstanceState) {
でしょうか。問題の説明と、場合によっては回答を追加してください。
package saintbedeslytham.saintbedes;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class news extends ActionBarActivity {
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent NameOfTheIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.st-bedes-high.lancsngfl.ac.uk/getfile.php?src=742/Christmas+Newsletter+2014.pdf"));
startActivity(NameOfTheIntent);
}
});
}
Button button2;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news);
button1 = (Button)findViewById(R.id.button2);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent NameOfTheIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.st-bedes-high.lancsngfl.ac.uk/getfile.php?src=742/Christmas+Newsletter+2014.pdf"));
startActivity(NameOfTheIntent);
}});
}}