Toask.makeText不能实现
Toask.makeText不能实现
控制台上能打印输出语句
package com.example.demo4;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
private Button bt1;
private Button bt2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt1=(Button) findViewById(R.id.button1);
bt2=(Button) findViewById(R.id.button2);
bt1.setOnClickListener(new Myclick(){
public void Onclick(View v)
{
super.onClick(v);
Toast.makeText(MainActivity.this, "bt1要执行的逻辑",1).show();
}
});
}
}
//外部类
class Myclick implements OnClickListener
{
public void onClick(View v)
{
Log.i("tag","父类的onClick事件");
}
}