-1

我正在使用相对布局,我试图弄清楚为什么我的 textViews 搞砸了。这是它的开始方式(点击放大)

在此处输入图像描述

但是当价值观明星进来时,它看起来像这样

在此处输入图像描述

这是我的xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="@string/inputVariables"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="84dp"
    android:text="@string/startingPoint"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/TextView01"
    android:layout_centerVertical="true"
    android:text="@string/calculatedPoint"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/speed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView3"
    android:layout_alignBottom="@+id/textView3"
    android:layout_alignLeft="@+id/heading"
    android:text="TextView" />

<TextView
    android:id="@+id/textView9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView1"
    android:layout_below="@+id/TextView02"
    android:layout_marginTop="14dp"
    android:text="@string/oneSecond" />

<TextView
    android:id="@+id/textView10"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView9"
    android:layout_below="@+id/textView8"
    android:layout_marginTop="25dp"
    android:text="@string/tenMilliSecond" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView9"
    android:layout_below="@+id/textView1"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="16dp"
    android:text="@string/heading" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView7"
    android:layout_below="@+id/textView2"
    android:text="@string/speed" />

<TextView
    android:id="@+id/oneSecondCalculatedPointLongitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView10"
    android:layout_alignLeft="@+id/oneSecondCalculatedLatitude"
    android:text="TextView" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:layout_below="@+id/textView9"
    android:layout_marginTop="16dp"
    android:text="@string/latitude" />

<TextView
    android:id="@+id/oneHundredMillisecondLatitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/oneSecondCalculatedPointLongitude"
    android:layout_below="@+id/textView10"
    android:layout_marginTop="18dp"
    android:text="TextView" />

<TextView
    android:id="@+id/textView11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/oneHundredMillisecondLatitude"
    android:layout_alignBottom="@+id/oneHundredMillisecondLatitude"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/latitude" />

<TextView
    android:id="@+id/oneHundredMillisecondLongitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/oneHundredMillisecondLatitude"
    android:layout_below="@+id/oneHundredMillisecondLatitude"
    android:text="TextView" />

<TextView
    android:id="@+id/textView12"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/oneHundredMillisecondLongitude"
    android:layout_alignBottom="@+id/oneHundredMillisecondLongitude"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/longitude" />

<TextView
    android:id="@+id/textView8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView7"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/longitude" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView5"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/longitude" />

<TextView
    android:id="@+id/startingPointLatitude"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/speed"
    android:layout_below="@+id/TextView01"
    android:layout_marginTop="26dp"
    android:text="TextView" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/startingPointLatitude"
    android:layout_alignBottom="@+id/startingPointLatitude"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/latitude" />

<TextView
    android:id="@+id/startingPointLongitude"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView6"
    android:layout_alignBottom="@+id/textView6"
    android:layout_alignLeft="@+id/startingPointLatitude"
    android:text="TextView" />

<TextView
    android:id="@+id/oneSecondCalculatedLatitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView8"
    android:layout_alignLeft="@+id/startingPointLongitude"
    android:text="TextView" />

<TextView
    android:id="@+id/heading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView2"
    android:layout_alignBottom="@+id/textView2"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/textView2"
    android:text="TextView" />

这是我正在更改 textView.texts 的代码

                    Location predicationPoint = DOTGpsAppUtils.predictionAlgorithm(latitude, longitude, 1, 100);

                double predictionLongitude = (longitude + predicationPoint.getLongitude())/2;
                double predictionLatitude = (latitude + predicationPoint.getLatitude())/2;

                TextView textView = (TextView) findViewById(R.id.oneHundredMillisecondLatitude);
                textView.setText(Double.valueOf(predictionLatitude).toString());

                textView = (TextView) findViewById(R.id.oneSecondCalculatedPointLongitude);
                textView.setText(Double.valueOf(predictionLongitude).toString());


                if(x == 9)
                {
                    longitude = predictionLongitude;
                    latitude = predictionLatitude;
                }

                System.out.println(x);

                ++x;
            }while(x < 10);

            TextView textView = (TextView) findViewById(R.id.startingPointLongitude);
            textView.setText(Double.valueOf(location.getLongitude()).toString());

            textView = (TextView) findViewById(R.id.startingPointLatitude);
            textView.setText(Double.valueOf(location.getLatitude()).toString());

            textView =  (TextView) findViewById(R.id.oneSecondCalculatedPointLongitude);
            textView.setText(Double.valueOf(longitude).toString());

            textView = (TextView) findViewById(R.id.oneSecondCalculatedLatitude);
            textView.setText(Double.valueOf(latitude).toString());
4

1 回答 1

0

在我看来,您将值分配给了错误的 TextView。

于 2013-09-09T06:13:15.113 回答