gpt4 book ai didi

android - textview 不显示文本(一个 TextView 将另一个 TextView 推离屏幕很远)

转载 作者:太空宇宙 更新时间:2023-11-03 12:59:31 30 4
gpt4 key购买 nike

现在 textview 显示如果我将滚动到底部的语句。看起来 promis textview 变大了。有办法解决吗?

screenshot星号下的所有内容都是 promis textview 的一部分。它是一个带有多个换行符的字符串 screenshot2另一个截图

生成 promise 的代码

prm = doc.getElementsByTagName("promise");
for (int j = 0; j < prm.getLength(); j++) {
prom += parser.getValue(e, KEY_PROMISES, j) + "\n";

}
prom.substring(0,prom.lastIndexOf('\n'));

布局

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

<RelativeLayout
android:id="@+id/top"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/face"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />

<TextView
android:id="@+id/name"
android:layout_width="243dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/face"
android:text="from" />

<TextView
android:id="@+id/office"
android:layout_width="242dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/face"
android:layout_alignParentRight="true"
android:layout_below="@+id/name"
android:layout_toRightOf="@id/face"
android:text="subject" />
</RelativeLayout>

<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/top"
android:numStars="6"
android:singleLine="false" />

<TextView
android:id="@+id/promises"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/ratingBar1"
android:layout_marginTop="5dp"
android:text="TextView" />

<ScrollView
android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/promises"
android:layout_marginRight="22dp"
android:layout_marginTop="26dp" >

<TextView
android:id="@+id/statement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</ScrollView>

</RelativeLayout>

我的应用的 Activity

public class SingleMenuItemActivity  extends Activity {


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.candidate);
Log.d("here ?", "No ");
int loader = R.drawable.loader;
// getting intent data
Intent in = getIntent();
Log.d("here ?", "No ");
// Get XML values from previous intent
String name = in.getStringExtra("name");
Log.d("Name ", name);
Log.d("here ?", "No ");
DatabaseHandler db = new DatabaseHandler(this);
Log.d("here ?", "No ");
Candidate p = db.getCandidate(name);
Log.d("Did i take candidate? ", "yea ");
db.close();
Log.d("Statement", p.get_statment());
// Displaying all values on the screen
TextView lblName = (TextView) findViewById(R.id.name);
TextView lblOffice = (TextView) findViewById(R.id.office);
TextView lblPromise = (TextView) findViewById(R.id.promises);
TextView lblStatement = (TextView) findViewById(R.id.statement);
ImageView lblFace = (ImageView) findViewById(R.id.face);
RatingBar lblRating = (RatingBar) findViewById(R.id.ratingBar1);
ImageLoader imgLoader = new ImageLoader(this);
lblName.setText(p.get_name());
lblOffice.setText(p.get_office());
lblPromise.setText(p.get_promises());
lblStatement.setText(p.get_statment());
lblRating.setRating(p.get_ranking());
imgLoader.DisplayImage(p.get_photograph(), loader, lblFace);

}
}

logcat 说 p.get_statment() 有适当的值(value)

12-16 05:07:16.089: D/Statement(279): I strive for the highest standards of appearance and personal grooming.  If, like me, you think that the University's reputation is being dragged down by lecturers who have little or no regard for fashion and are content to wear ill-fitting or patched clothes then vote for me: the stylish choice.

声誉太低,无法发布图片 %)

最佳答案

看起来您的 RatingBar 覆盖了您的 statement TextView:

<RatingBar
android:layout_above="@+id/statement"
... />

也许你的意思是 layout_below

此外,您的 promises TextView 的上边距非常大,它可能会将 statement TextView 推离屏幕底部:

<TextView
android:id="@+id/promises"
android:layout_marginTop="124dp"
... />

添加
显然,在您的 promises TextView 末尾还有一些换行符。如果您无法从源中删除这些字符,您可以使用 trim() :

prom = prom.trim();

关于android - textview 不显示文本(一个 TextView 将另一个 TextView 推离屏幕很远),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13898837/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com