2011-07-15 213 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 ....

每當你想要發生只是執行那三個陳述, ,將做你的工作....