我创建了三个等重的线性布局。在其中一个线性布局中,我有 6 个文本视图。我已经在我的活动中初始化了文本视图。但我无法查看此文本视图。我不知道我要去哪里错了。请帮我。
这是我的 XML 布局
<?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:orientation="vertical" >
<LinearLayout
android:id="@+id/lay"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<TextView android:id="@+id/num1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#000000"
android:textSize="10dip"
android:layout_weight="1" />
<TextView android:id="@+id/date1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="#000000"
android:textSize="10dip"
android:layout_marginLeft="10dp"
android:layout_weight="1" />
<TextView android:id="@+id/cus1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#000000"
android:textSize="10dip" />
<TextView android:id="@+id/service1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#000000"
android:textSize="10dip" />
<TextView android:id="@+id/job1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#000000"
android:textSize="10dip" />
<TextView android:id="@+id/des1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#000000"
android:textSize="10dip" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#FFFFFF" >
<EditText
android:id="@+id/EditTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/followup"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#FFFFFF" />
</LinearLayout>
这是我的活动
public class Detail extends Activity{
String value1 , value2;
Cursor c, c1;
DataBaseHelper myDbHelper = new DataBaseHelper(this);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
LinearLayout ll = (LinearLayout) findViewById(R.id.lay);
TextView tv1 =(TextView)ll.findViewById(R.id.num1);
TextView tv2 =(TextView)ll.findViewById(R.id.date1);
TextView tv3 =(TextView)ll.findViewById(R.id.cus1);
TextView tv4 =(TextView)ll.findViewById(R.id.service1);
TextView tv5 =(TextView)ll.findViewById(R.id.job1);
TextView tv6 =(TextView)ll.findViewById(R.id.des1);
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
value1 = extras.getString("keyName");
value2 = extras.getString("keyTime");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
myDbHelper.setSearch(value1);
c = myDbHelper.getDetail();
if(c.getCount()!=0){
c.moveToFirst();
while (!c.isAfterLast()) {
tv1.setText("Ticket No:" + c.getString(c.getColumnIndex("taskID")));
tv2.setText("Date:" + value2 + "/" + c.getString(c.getColumnIndex("time")) );
tv3.setText("Customer Name:" + value1);
tv4.setText("Description:" + c.getString(c.getColumnIndex("taskDetail")));
c.moveToNext();
}
c.close();
}
myDbHelper.setSearch(value1);
c1 = myDbHelper.getService();
if(c1.getCount()!=0){
c1.moveToFirst();
while (!c1.isAfterLast()) {
tv5.setText("Service Type:" + c1.getString(c1.getColumnIndex("description")));
tv6.setText(value1);
c1.moveToNext();
}
c1.close();
}
myDbHelper.close();}}
我想要这样的布局, 前两个文本在同一行,一个在右边,另一个在左角,另外四个垂直向下。如何做到这一点?