0
有麻烦布局吹气工作 - 如果有人得到阐明为什么文本视图不工作的一些光想知道..不能得到吹气布局工作
这是main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center_horizontal"
android:background="#A9BCF5"
android:orientation="vertical"
tools:context=".MainActivity"
android:weightSum="1">
<ImageView
android:layout_width="639dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:id="@+id/imageView"
android:background="@drawable/retreatgoddess"
android:scaleType="centerCrop"
android:clickable="true"
android:cropToPadding="false"
android:longClickable="false"
android:layout_weight="0.80" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/affirmation"
android:layout_weight="0.23"
android:textAlignment="center"
android:textColor="#1728ff"
android:textStyle="normal"
android:typeface="sans"/>
</LinearLayout>
这是通过
fillTextView(context, R.layout.main, R.id.affirmation, "i love you");
方法
public void fillTextView(Context context, int layoutId, int resId, String text)
{
View view= LayoutInflater.from(context).inflate(layoutId, null);
TextView textElement = (TextView) view.findViewById(resId);
textElement.setText(text);
}
我打电话它
我得到的背景,但没有文字
你在哪里添加视图到活动 – Raghunandan
您使用的是EditText对象,并且在充气器中您调用了TextView –