标签:android style class java ext color
今天研究了一下如何写最基本的Android程序,为Button添加单击等事件。自己在动手的时候确实遇到了很多问题,同时自己从上午的零基础的状态,到下午做出来一个成品app,还是挺兴奋滴~尤其是里面的控件,自己看说明或者网上查资料使用,逐步探索的过程~
下面记录一下Button单击事件~
public class MainActivity extends Activity {
Button myButton;
TextView myTextView;
@SuppressLint("SetJavaScriptEnabled") @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
myButton = (Button) findViewById(R.id.button1);
myTextView = (TextView) findViewById(R.id.textView2);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myTextView.setText("单击事件");
}
});
myButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
myTextView.setText("longClick!");
return false;
}
});
}
标签:android style class java ext color
原文地址:http://www.cnblogs.com/510602159-Yano/p/3784624.html