这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="@drawable/tab_color_red" >
<TextView
android:id="@+id/_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/bar"
android:ellipsize="end"
android:paddingLeft="5dip"
android:singleLine="true"
android:textColor="#ffffff"
android:textSize="15dip"
android:textStyle="bold" />
<ProgressBar
android:id="@+id/bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="invisible" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="6dip"
android:background="@drawable/noselect_blue"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/direzione"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:text="@string/vehicleDirection"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="@+id/direzione_value"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/id_veicolo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:text="@string/lineID"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="@+id/id_veicolo_value"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/id_fermata"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:text="@string/stopID"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="@+id/id_fermata_value"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tempo_arrivo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:text="@string/vehicleTimeLeft"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="@+id/tempo_arrivo_value"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/pbus_spec_panel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="6dip"
android:background="@drawable/noselect_blue"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:id="@+id/pbus_specs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/pbusSpecs"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="@+id/desc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="2dip"
android:gravity="center"
android:textColor="#000000"
android:textSize="12sp"
android:visibility="visible"
android:text="@string/pbusSpecs"
android:textStyle="italic" />
<LinearLayout
android:id="@+id/inner_pbus_spec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:visibility="visible">
<TextView
android:id="@+id/credibility"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginTop="6dip"
android:gravity="center"
android:text="@string/pbusTrust"
android:textColor="#000000"
android:textSize="12sp"
android:textStyle="bold" />
<ProgressBar
android:id="@+id/barraCredibilita"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="200dip"
android:layout_height="15dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="6dip"
android:background="@drawable/noselect_blue"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dip"
>
<TextView
android:id="@+id/visualizza_percorso"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_toLeftOf="@+id/percorso_freccia"
android:text="@string/vehicleActionSeePath"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="italic" />
<ImageView
android:id="@+id/percorso_freccia"
android:layout_width="30dip"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:gravity="left"
android:scaleType="center"
android:src="@drawable/expander_ic" />
</RelativeLayout>
<View
android:id="@+id/View02"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginTop="5dip"
android:background="@color/line" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dip"
android:id="@+id/pbus_confirm_layout"
android:visibility="gone"
>
<TextView
android:id="@+id/quick_confirm"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="@+id/conferma_freccia"
android:gravity="center"
android:text="@string/confirmVehicle"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="italic" />
<ImageView
android:id="@+id/conferma_freccia"
android:layout_width="30dip"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:gravity="left"
android:scaleType="center"
android:src="@drawable/expander_ic" />
</RelativeLayout>
<View
android:id="@+id/middle_line"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginTop="5dip"
android:background="@color/line"
android:visibility="gone"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dip"
>
<TextView
android:id="@+id/aggiungi_info"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="@+id/aggiungi_freccia"
android:gravity="center"
android:text="@string/addVehicleInfos"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="italic" />
<ImageView
android:id="@+id/aggiungi_freccia"
android:layout_width="30dip"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="left"
android:scaleType="center"
android:src="@drawable/expander_ic" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
这是我的活动:
package com.atacmobile;
import java.util.HashMap;
import com.atacmobile.Model.Costants;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class MoreInfoBus extends Activity{
private static Context context;
boolean isPbus;
String atacid;//id fermata
String bus;
String pathid;
String lineid;
String azione;
String direzione;
String tempoFermateRimanente;
HashMap<String, String> map = new HashMap<String,String>();
int conferme;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
context = getApplicationContext();
setContentView(R.layout.moreinfobus);
azione=getIntent().getAction();
if(azione.equals("infobus")){
Bundle extras = getIntent().getExtras();
atacid=extras.getString(Costants.ATACID);
bus=extras.getString(Costants.BUS);
pathid=extras.getString(Costants.PATHID);
lineid=extras.getString(Costants.LINEID);
isPbus = extras.getBoolean(Costants.PBUS);
direzione = extras.getString(Costants.DIRECTION);
tempoFermateRimanente = extras.getString(Costants.TIMELEFT);
if(isPbus){
conferme = extras.getInt(Costants.CONFIRMS);
}
}
TextView titolo=(TextView)findViewById(R.id._title);
titolo.setText("INFO. LINEA "+bus);
TextView direction = (TextView)findViewById(R.id.direzione_value);
TextView id_veicolo = (TextView)findViewById(R.id.id_veicolo_value);
TextView id_palina = (TextView)findViewById(R.id.id_fermata_value);
TextView tempo_arrivo = (TextView)findViewById(R.id.tempo_arrivo_value);
direction.setText(direzione);
id_veicolo.setText(lineid);
id_palina.setText(atacid);
tempo_arrivo.setText(tempoFermateRimanente);
if(isPbus){
LinearLayout lin_lay = (LinearLayout)findViewById(R.id.pbus_spec_panel);
lin_lay.setVisibility(View.VISIBLE);
RelativeLayout rel_lay = (RelativeLayout)findViewById(R.id.pbus_confirm_layout);
rel_lay.setVisibility(View.VISIBLE);
View line = (View)findViewById(R.id.middle_line);
line.setVisibility(View.VISIBLE);
TextView infos = (TextView)findViewById(R.id.pbus_specs);
infos.setVisibility(View.VISIBLE);
TextView desc = (TextView)findViewById(R.id.desc);
desc.setText("Questo autobus non è monitorato da ATAC ed è stato segnalato da altri utenti che utilizzano RMob! Esattamente "+conferme+" utente\\i hanno confermato quest'autobus!");
desc.setVisibility(View.VISIBLE);
ProgressBar pb = (ProgressBar)findViewById(R.id.barraCredibilita);
pb.setMax(5);
int d = 0;
if(conferme == 0) d = R.drawable.redprogressbar;
else if(conferme<=2) d = R.drawable.yellowprogressbar;
else d = R.drawable.greenprogressbar;
pb.setProgressDrawable(context.getApplicationContext().getResources().getDrawable(d));
pb.setProgress(conferme<4?conferme+1:pb.getMax());
pb.setVisibility(View.VISIBLE);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
}
// Checks whether a hardware keyboard is available
if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
} else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
}
}
}
上面的布局显示了除了TextView desc
和所有LinearLayout
带有 id的所有内容inner_pbus_spec
。我究竟做错了什么?我可以在 Eclipse 的可视化编辑器中看到所有内容!