Cant set text in TextView - android

2019-08-30 12:26发布

I checked every topic on stack about textView. I have problems with changing my content in TextView control.

public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    super.onCreate(savedInstanceState);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    final ViewPager mViewPager;
    mViewPager = (ViewPager) getActivity().findViewById(R.id.pager);

    LayoutInflater inflater = getActivity().getLayoutInflater();
    builder.setView(inflater.inflate(R.layout.dialog_layout, null));

    final View rootView = inflater.inflate(R.layout.dialog_layout, null);


    przystanekStartowy = (TextView) rootView.findViewById(R.id.przystanekStartowy);
    przystanekKoncowy = (TextView) rootView.findViewById(R.id.przystanekKoncowy);

    a1=getArguments().getString("1");
    a2=getArguments().getString("2");

    przystanekStartowy.setText((CharSequence)a1);
    przystanekKoncowy.setText((CharSequence)a2);

I checked the values in debugger, everything is okay, a1 and a2 contains good strings.

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical" >

 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="horizontal" >

 <ImageView
     android:id="@+id/vehicle_image"
     android:layout_width="50dip"
     android:layout_height="50dip"
     android:src="@drawable/autobus_ico"
     android:layout_marginLeft="5dip"/>

  <TextView
     android:id="@+id/przystanekStartowy"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Escriba"
     android:typeface="sans"
    android:layout_marginLeft="10dip"
    android:layout_marginTop="12dip"
    android:textSize="18sp" />

 <ImageView
     android:id="@+id/arrow_image"
     android:layout_width="25dip"
     android:layout_height="25dip"
     android:src="@drawable/ic_action_forward"
     android:layout_marginLeft="5dip"
     android:layout_marginTop="12dip"/>

 <TextView
     android:id="@+id/przystanekKoncowy"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Escriba"
     android:typeface="sans"
    android:textSize="18sp"
    android:layout_marginTop="12dip" />

 </LinearLayout>
 </LinearLayout>

Thank you for your help

0条回答
登录 后发表回答