我有以下代码来设置EditText
标题栏(主流程)的值,但它失败并且没有分配任何值。
你能告诉我怎么setText
做吗?
以下是我的代码(我的主活动)
@SuppressWarnings("deprecation")
public class MainActivity extends Activity
{
private AsyncTask <Void , Void, Void> mRegisterTask ;
private String userid;
private String orderid;
...
View inflatedView = getLayoutInflater().inflate(R.layout.activity_main, null);
final EditText s = (EditText) inflatedView.findViewById(R.id.textView2);
userid = "99999";
s.setText(userid);
活动主
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="@drawable/bg_with_header"
android:padding="0dp"
tools:context=".MainActivity" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:padding="0dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:orientation="vertical"
android:padding="0dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="82dp"
android:layout_margin="0dp"
android:layout_marginRight="50dp"
android:orientation="horizontal"
android:padding="0dp" >
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:src="@drawable/header_tv1231231231231bnvlogo" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="82dp"
android:layout_gravity="center"
android:layout_toLeftOf="@+id/headerLogin"
android:scrollbars="none" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="300dp"
android:layout_height="86dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:showDividers="none"
android:tabStripEnabled="false" />
</HorizontalScrollView>
<RelativeLayout
android:id="@+id/headerLogin"
android:layout_width="wrap_content"
android:layout_height="82dp"
android:orientation="horizontal" >
<EditText
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/txtbg"
android:ems="10"
android:enabled="false"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding=" 5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#BDBDBD" />
<EditText
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/textView1"
android:background="@drawable/txtbg"
android:ems="10"
android:enabled="false"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#BDBDBD" />
<TextView
android:id="@+id/textVieasas2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textVieasas"
android:layout_alignBottom="@+id/textVieasas"
android:layout_toRightOf="@+id/textView2"
android:text="Last Login Date"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<TextView
android:id="@+id/textVieasas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_alignLeft="@+id/textView2"
android:text="Sales Code"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:padding="0dp" />
</LinearLayout>
</TabHost>