标签:
package com.example.tianchu;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class DialogActivity extends Activity {
RelativeLayout linear = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.setContentView(R.layout.daactivity_main);
this.linear = (RelativeLayout) super.findViewById(R.id.tianchu);
this.linear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(DialogActivity.this, "你点击了这个弹出窗口咯",
Toast.LENGTH_SHORT).show();
}
});
}
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
this.finish();// 结束本Activity
return super.onTouchEvent(event);
}
}
package com.example.tianchu;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉顶部标题
super.setContentView(R.layout.activity_main);
Button mybut = (Button) super.findViewById(R.id.button1);
mybut.setOnClickListener(new OnClickListener() {
public void onClick(View v) { // TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "弹出了一个窗口哦",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this,
DialogActivity.class);
MainActivity.this.startActivity(intent);
}
});
}
}
17:51:53 2015-08-21
标签:
原文地址:http://www.cnblogs.com/wang251/p/4748586.html