2014-02-09 4 views
0

저는 SlidingMenu을 사용하고 있으며 메뉴 조각에 포함 된 TextView를 업데이트하려고합니다.TextView가 SlidingMenu로 업데이트되지 않습니다

제 문제는 setText()를 호출 할 때 텍스트가 변경되지 않지만 Log.i ("".getText())를 호출 한 후 새 텍스트를 인쇄하면 문제가 생깁니다.

내가

public class SlidingMenuListFragment extends SherlockListFragment { 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     this.container = container; 
     return inflater.inflate(R.layout.menu_slide_menu, container, false); 
    } 

    @Override 
    public void onActivityCreated(Bundle savedInstanceState) { 
     super.onActivityCreated(savedInstanceState); 

     adapter = new SlidingMenuListAdapter(getActivity(), 
     R.layout.menu_slide_menu_item, MenuItems); 

     Username = (TextView) container.findViewById(R.id.username); 

     Username.setText("NEW VALUE"); 
     Log.i("ASD", Username.getText().toString()); // prints the new value! 

     setListAdapter(adapter); 
    } 
} 

레이아웃 어떤 결과없이 mytextview.invalidate()를 호출하려고 :

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#f2f2f2" 
     android:orientation="vertical" > 

     ... 

    <RelativeLayout 
     android:id="@+id/username_layout" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/abs__action_bar_default_height" 
     android:background="@drawable/actionbar" > 

     ... 

     <TextView 
      android:id="@+id/username" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_toRightOf="@+id/textView1" 
      android:text="asd" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#ffffff" 
      android:textStyle="bold" /> 
    </RelativeLayout> 

    <ListView 
     android:id="@+id/menu_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="#f2f2f2" 
     android:dividerHeight="0dip" 
     android:textSize="32sp" /> 
     </LinearLayout> 

</FrameLayout> 

답변