android studioでアプリの勉強をしているのですが、setOnClickListenerでエラーが出ます。
android studioは最新版にアップデートし、設定は以前のままで行いました。
以下にプログラムを貼ります。
package com.example.keitaro.browser;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } Button btn = (Button)findViewById(R.id.btn1); TextView text = (TextView)findViewById(R.id.text1); btn.setOnClickListener(new onClickListener(){ //ここでエラーがでます。 Log.v(btn); @Override public void onClick(View v){ String s = "押された"; text.setText(s); } }); @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); }
}
解決策がありましたら、教えて下さい。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/07/12 02:04