2011-07-15 59 views
0

上我有一个Android的应用程序中,我想实现以下的事情:点击android手机屏幕

我想通过点击python脚本在Android手机的图像上。

有谁知道我该怎么做到这一点?

回答

2

您可以使用单个按钮创建布局。将该按钮的背景设置为所需的图像。使按钮的宽度和高度与父级匹配。然后以正常方式注册按钮以开始活动。因此,像这样:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <Button 
     android:layout_width="match_parent" 
     android:id="@+id/button1" 
     android:layout_height="match_parent" 
     android:background="@drawable/background"> 
    </Button> 
</LinearLayout> 

与您的活动是这样的:

public class ActivityA extends Activity implements OnClickListener 
{ 

    @Override 
    public void onCreate(Bundle icicle) 
    { 
     super.onCreate(icicle); 
     setContentView(R.layout.main); 
     Button buttonA = (Button) findViewById(R.id.button1); 
     buttonA.setOnClickListener(this); 
    } 

    @Override 
    public void onClick(View v) { 
     final Intent intent = new Intent(getApplicationContext(), ActivityB.class); 
     startActivity(intent); 
    } 
} 

当用户按下“返回”,他或她将回到巨人按钮活动。

0

,每当你想移动从一个活动到另一个活动,请试试这个..

Intent myIntent = new Intent(CurrentActivity.this,NextActivity.class); 
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
startActivity(myIntent); 

上面的代码将带你从CurrentActivityNextActivity ....

每当你想要发生只是执行那三个陈述, ,将做你的工作....