我在这个 click_screen 上放置了点击事件
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="click_screen" />
另一个活动的 .java 文件 (click_screen)
public void click_screen(View v)
{
Intent click_screen=new Intent(this, MainActivity.class);
startActivity(click_screen);
}
MainActivity.java
package com.amcct.amcostapp;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity
{
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/* @Override
public boolean onTouchEvent(MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_DOWN)
{
Intent click_screen=new Intent(this, MainActivity.class);
startActivity(click_screen);
}
return super.onTouchEvent(event);
}*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void click_screen(View v)
{
Intent click_screen=new Intent(this, MainActivity.class);
startActivity(click_screen);
}
}
==================================================== =================== .xml 当我点击任何地方时它会在 click_screen 上方生成 ^^
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:onClick="click_screen"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Click_Page"
android:background="@drawable/img_1" >
</RelativeLayout>
看到这个我的所有文件....