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: 'Raf'\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: 'Dakke'\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: 'Tommeke'\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: 'der Schutz'\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>