2015-01-09 6 views
1

내 응용 프로그램에서 나는 Navigation Drawer, ListViewNavigatinDrawer' has an ImageView , TextView and another TextView with id tv_navDrawerOptionDescription의 아래에 나와 있습니다.navigationdrawer marquee의 listview에서 모든 textView를 동시에 만드는 방법은 무엇입니까?

탐색 서랍의 ListView에있는 항목의 수는 세 가지 항목 (환경 지원, 데이터 로거 출구) 그들 각각은 "제목으로"이미지 뷰, 텍스트 뷰를 가지고

"설명과 같은"다른 텍스트 뷰입니다

내가 원하는 것은, 서랍을 열었을 때, 내가 가지고있는 세 가지 항목의 모든 "description TextView"가 NavigationDrawerListView에 수평으로 회전해야합니다. 영원히는 marquee입니다.

내가 앱을 실행할 때.

public class NavDrawerListAdapter extends BaseAdapter{ 

private Context context; 
private ArrayList<NavDrawerModell> navDrawerModel; 

public NavDrawerListAdapter(Context context, ArrayList<NavDrawerModell> navDrawerModell) { 
    // TODO Auto-generated constructor stub 
    this.context = context; 
    this.navDrawerModel = navDrawerModell; 
} 

@Override 
public int getCount() { 
    // TODO Auto-generated method stub 
    return this.navDrawerModel.size(); 
} 

@Override 
public Object getItem(int position) { 
    // TODO Auto-generated method stub 
    return this.navDrawerModel.get(position); 
} 

@Override 
public long getItemId(int position) { 
    // TODO Auto-generated method stub 
    return position; 
} 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    // TODO Auto-generated method stub 
    if (convertView == null) { 
     LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); 
     convertView = layoutInflater.inflate(R.layout.drawer_list_layout, null); 
    } 

    ImageView iv_Icon = (ImageView) convertView.findViewById(R.id.iv_navDrawerOptionImage); 
    TextView tv_Title = (TextView) convertView.findViewById(R.id.tv_navDrawerOptionTitle); 
    TextView tv_Desc = (TextView) convertView.findViewById(R.id.tv_navDrawerOptionDescription); 

    iv_Icon.setImageResource(navDrawerModel.get(position).getIcon()); 
    tv_Title.setText(navDrawerModel.get(position).gettitle()); 
    tv_Desc.setText(navDrawerModel.get(position).getDescription()); 

    return convertView; 
    } 
    } 
: 내가 설명 textview 정적이며

내 시도가 belwo navigationDrawer

의 목록보기
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/list_selector"> 

<ImageView 
    android:id="@+id/iv_navDrawerOptionImage" 
    android:layout_width="25dp" 
    android:layout_height="wrap_content" 
    android:layout_alignParentStart="true" 
    android:layout_marginLeft="12dp" 
    android:layout_marginRight="12dp" 
    android:contentDescription="@string/desc_list_item_icon" 
    android:layout_centerVertical="true"/> 

<TextView 
    android:id="@+id/tv_navDrawerOptionTitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toEndOf="@id/iv_navDrawerOptionImage" 
    android:minHeight="?android:attr/listPreferredItemHeightSmall" 
    android:textAppearance="?android:attr/textAppearanceListItemSmall" 
    android:textColor="@color/list_item_title" 
    android:gravity="center_vertical"/> 

    <TextView 
    android:id="@+id/tv_navDrawerOptionDescription" 
    android:layout_below="@id/tv_navDrawerOptionTitle" 
    android:singleLine="true" 
    android:lines="1" 
    android:ellipsize="marquee" 
    android:fadingEdge="horizontal" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

NavigationDrawer ListAdapter의 레이아웃을 게시 회전하지 발견

답변

2
<TextView 
android:id="@+id/tv_navDrawerOptionDescription" 
android:layout_below="@id/tv_navDrawerOptionTitle" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:singleLine="true" 
android:ellipsize="marquee" 
android:marqueeRepeatLimit="marquee_forever" 
android:scrollHorizontally="true"> 

위 코드를 시도해보고 이것이 작동하는지 확인하십시오.

편집 :

다음 코드를 추가 BaseAdapter 서브 클래스의 getView 기능에서

:

tv_Desc.setText(navDrawerModel.get(position).getDescription()); 
tv_Desc.setSelected(true); 
tv_Desc.requestFocus(); 
+0

은 "안드로이드 : 포커스 ="true "로 안드로이드 : focusableIn TouchMode를이 =" "의 목록보기를 사실 확인 navigationdrawer freez 그래서 listView에있는 다른 항목을 선택할 수 없습니다. 나는 또한이 두 줄을 시도했다. 나는 "android : freezesText ="true "를 추가했다. 그리고 이것들은 텍스트가 여전히 정적이다. – rmaik

+0

아이디어가 정확하다. 하지만 "tv_Desc"는 "tv_Title"이 아니라 참조되어야하는 것입니다. 대신 "tv_Desc"가되도록 anser를 편집하십시오. o "tv_title" – rmaik

+0

tv_Title 대신 tv_Desc를 사용하도록 코드가 수정되었습니다. –