2013-07-22 44 views
1

我正在爲我的android手機與eclipse基本應用程序。這是一個簡單的基本應用程序,提供有關學生組的信息。該應用程序有7個佈局的:家庭,聯繫人,歷史,...圖片鏈接到eclipse Android應用程序開發

在主屏幕上有6個圖像,這些圖像是可點擊的,所以你可以去其他佈局。但過了一段時間,我發現一些圖像相互關聯。

示例: 以下是2佈局,主屏幕和Praesidiumscreen的代碼。在這2個佈局中有2個圖像被鏈接。請注意,在主屏幕中,圖像有一個id IvRaf,在Praesidium屏幕中有一個圖像IvRaf。如果我想更改1張圖像的ID,則其他圖像的ID也會更改。

有人知道我該如何解決這個問題?有更多的圖像有相同的問題。如果你需要更多的信息,我可以給它。或者我可以發送給你整個應用程序。

這是主屏幕的代碼:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="409dp" > 

    <ImageView 
     android:id="@+id/iVRaf" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:adjustViewBounds="true" 
     android:baselineAlignBottom="false" 
     android:cropToPadding="true" 
     android:scaleType="fitXY" 
     android:src="@drawable/bannerapp" /> 

    <ImageView 
     android:id="@+id/iVPraesidium" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/iVRaf" 
     android:adjustViewBounds="true" 
     android:onClick="clickPraesidium" 
     android:src="@drawable/bannerpraesidium" /> 

    <ImageView 
     android:id="@+id/iVKalender" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/iVPraesidium" 
     android:adjustViewBounds="true" 
     android:onClick="clickKalender" 
     android:src="@drawable/banner_kalender" /> 

    <ImageView 
     android:id="@+id/iVGeschiedenis" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/iVKalender" 
     android:adjustViewBounds="true" 
     android:onClick="clickGeschiedenis" 
     android:src="@drawable/bannergeschiedenis" /> 

    <ImageView 
     android:id="@+id/iVKringlied" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="false" 
     android:layout_below="@+id/iVGeschiedenis" 
     android:adjustViewBounds="true" 
     android:onClick="clickKringlied" 
     android:src="@drawable/banner_kringlied2" /> 

    <ImageView 
     android:id="@+id/iVContact" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/iVKringlied" 
     android:adjustViewBounds="true" 
     android:onClick="clickContact" 
     android:src="@drawable/banner_contact" /> 

    <ImageView 
     android:id="@+id/iVSponsors" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="false" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/iVContact" 
     android:adjustViewBounds="true" 
     android:onClick="clickSponsors" 
     android:src="@drawable/banner_sponsors" /> 

</RelativeLayout> 

</ScrollView> 

這是的Praesidiumscreen的代碼:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageView 
     android:id="@+id/iVTopBannerPraesidium" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:scaleType="fitXY" 
     android:src="@drawable/topbanner_praesidium" /> 

    <TextView 
     android:id="@+id/tVPraeses" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/iVRaf" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/iVTopBannerPraesidium" 
     android:layout_centerInParent="false" 
     android:layout_marginLeft="86dp" 
     android:layout_marginTop="2dp" 
     android:text="Praeses: Rafaël Vercammen" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/tVInfoPraeses" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVPraeses" 
     android:layout_alignParentBottom="false" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/tVPraeses" 
     android:layout_marginTop="5dp" 
     android:text="Vulgo: &apos;Raf&apos;\nThuis-adres: Grasheide\nLid sinds 2011\nStudierichting: EM-Klima\nContact: [email protected]" /> 

    <ImageView 
     android:id="@+id/iVDaan" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/iVRaf" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="false" 
     android:layout_below="@+id/tVInfoPraeses" 
     android:layout_marginRight="237dp" 
     android:layout_marginTop="34dp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/daan" /> 

    <ImageView 
     android:id="@+id/iVRaf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/iVTopBannerPraesidium" 
     android:layout_centerInParent="false" 
     android:layout_marginRight="237dp" 
     android:layout_marginTop="12dp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/raf" /> 

    <TextView 
     android:id="@+id/tVVice" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVInfoPraeses" 
     android:layout_below="@+id/tVInfoPraeses" 
     android:layout_marginTop="20dp" 
     android:text="Vice-Praeses: Daan Gybels" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/tVInfoVice" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVVice" 
     android:layout_below="@+id/tVVice" 
     android:layout_marginTop="5dp" 
     android:text="Vulgo: &apos;Dakke&apos;\nKot-adres: Kot Leon\nThuis-adres: Tremelo\nLid sinds 2011\nStudierichting: OP\nContact: [email protected]" /> 

    <ImageView 
     android:id="@+id/iVTom" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/iVDaan" 
     android:layout_alignParentTop="false" 
     android:layout_alignRight="@+id/iVDaan" 
     android:layout_below="@+id/tVInfoVice" 
     android:layout_marginTop="34dp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/tom" /> 

    <TextView 
     android:id="@+id/tVAbactis" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVInfoVice" 
     android:layout_below="@+id/tVInfoVice" 
     android:layout_marginTop="20dp" 
     android:text="Ab-Actis: Tom Hermans" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/tVInfoAbactis" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVAbactis" 
     android:layout_below="@+id/tVAbactis" 
     android:layout_marginTop="5dp" 
     android:text="Vulgo: &apos;Tommeke&apos;\nThuis-adres: Rijmenam\nLid sinds 2012\nStudierichting: Elektronica-ICT\nContact: [email protected]" /> 

    <ImageView 
     android:id="@+id/iVWouter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/iVTom" 
     android:layout_alignParentTop="false" 
     android:layout_alignRight="@+id/iVTom" 
     android:layout_below="@+id/iVTom" 
     android:layout_marginTop="34dp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/wouter" /> 

    <TextView 
     android:id="@+id/tVQuaestor" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVInfoAbactis" 
     android:layout_below="@+id/iVTom" 
     android:layout_marginTop="20dp" 
     android:text="Quaestor: Wouter De Schutter" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/tVInfoQuaestor" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVQuaestor" 
     android:layout_below="@+id/tVQuaestor" 
     android:layout_marginTop="5dp" 
     android:text="Vulgo: &apos;der Schutz&apos;\nThuis-adreLid sinds 2010s: Muizen\nLid sinds 2010\nStudierichting: EM-Auto\nContact: [email protected]" /> 

    <ImageView 
     android:id="@+id/iVKyani" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/iVWouter" 
     android:layout_alignParentTop="false" 
     android:layout_alignRight="@+id/iVWouter" 
     android:layout_below="@+id/iVWouter" 
     android:layout_marginTop="34dp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/kyani" /> 

    <TextView 
     android:id="@+id/tVFeestleider" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVInfoQuaestor" 
     android:layout_below="@+id/iVWouter" 
     android:layout_marginTop="20dp" 
     android:text="Feestleider: Kyani Vullings" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/tVInfoFeestleider" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVFeestleider" 
     android:layout_below="@+id/tVFeestleider" 
     android:layout_marginTop="5dp" 
     android:text="Kot-adres: Berthouders\nThuis-adres: Panningen\nLid sinds 2012\nStudierichting: OP\nContact: [email protected]" /> 

    <ImageView 
     android:id="@+id/iVStef" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/iVKyani" 
     android:layout_alignRight="@+id/iVKyani" 
     android:layout_below="@+id/iVKyani" 
     android:layout_marginTop="34dp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/stef" /> 

    <TextView 
     android:id="@+id/tVSpocul" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVInfoFeestleider" 
     android:layout_below="@+id/iVKyani" 
     android:layout_marginTop="20dp" 
     android:text="Spocul: Stef Van Wolputte" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/tVInfoSpocul" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tVSpocul" 
     android:layout_below="@+id/tVSpocul" 
     android:layout_marginTop="5dp" 
     android:text="Kot-adres: Kot Leon\nThuis-adres: Herenthout\nLid sinds 2010\nStudierichting: Elektronica-Schakel\nContact: [email protected]\n" /> 

</RelativeLayout> 

</ScrollView> 

這是主程序:

package com.example.mereta; 

import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.view.KeyEvent; 
import android.view.Menu; 
import android.view.View; 
import android.widget.ImageView; 

public class MainActivity extends Activity { 

    ImageView mImageGeschiedenis; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.home); 
    mImageGeschiedenis = (ImageView) findViewById(R.id.iVGeschiedenis); 
} 

public void clickGeschiedenis(View view){ 
    startActivity(new Intent("com.example.mereta.Geschiedenis")); 
} 

public void clickPraesidium(View view){ 
    startActivity(new Intent("com.example.mereta.Praesidium")); 
} 

public void clickKringlied(View view){ 
    startActivity(new Intent("com.example.mereta.KringLied")); 
} 

public void clickSponsors(View view){ 
    startActivity(new Intent("com.example.mereta.Sponsors")); 
} 

public void clickContact(View view){ 
    startActivity(new Intent("com.example.mereta.Contact")); 
} 

public void clickKalender(View view){ 
    startActivity(new Intent("com.example.mereta.Kalender")); 
} 

@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; 
} 

}

這是Android清單

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.mereta" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="7" 
    android:targetSdkVersion="7" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.example.mereta.MainActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
      <activity 
     android:name=".Geschiedenis" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="com.example.mereta.Geschiedenis" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
        <activity 
     android:name=".Contact" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="com.example.mereta.Contact" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
        <activity 
     android:name=".Kalender" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="com.example.mereta.Kalender" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
        <activity 
     android:name=".KringLied" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="com.example.mereta.KringLied" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
        <activity 
     android:name=".Praesidium" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="com.example.mereta.Praesidium" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
        <activity 
     android:name=".Sponsors" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="com.example.mereta.Sponsors" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
</application> 

回答

0

嘗試implelemt意圖這樣

intent.setAction(this, SecondActivity.class); 
    startActivity(intent); 

,而不是

startActivity(new Intent("com.example.mereta.Geschiedenis"));  

另一件事嘗試添加完成();在每次背部按壓活動 因此,當您開始另一項活動時,您將完成每項活動