2013-08-23 11 views
14

chcę użyć SeekBar w panel nawigacjiSeekBar w NavigationDrawer

Zasadniczo muszę przesunąć w lewo i prawo, aby ustawić SeekBar i dobrze, zgadliście, to wsuwa szufladę nawigacji ...

To, co chciałbym zrobić, to przesunąć pasek wyszukiwania, gdy jest on skupiony, a kula nawigacyjna, gdy nie jest.

Jak mam to zrobić?

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/critere_item" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:stretchColumns="*"> 

    <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:text="Large Text" 
       android:id="@+id/critere_title" 
       android:layout_gravity="left|center_vertical" 
       android:layout_column="0"/> 

     <SeekBar 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/critere_qualifier" 
       android:layout_column="1" 
       android:layout_span="4"/> 
    </TableRow> 

    <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="Medium Text" 
       android:id="@+id/critere_value" 
       android:layout_span="4"/> 
    </TableRow> 

</TableLayout> 

z góry dzięki :)

: Podczas ustawiania elementu (nie ustawiono jeszcze SeekBar)

private View onCritereView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 

    View mView = inflater.inflate(R.layout.fragment_critere, container, false); 
    LinearLayout mLinearLayout = (LinearLayout) mView.findViewById(R.id.critere_linearlayout); 

    View mViewElement = inflater.inflate(R.layout.item_critere, null); 
    ((TextView)mViewElement.findViewById(R.id.critere_title)).setText("Prix Maximum"); 

    mLinearLayout.addView(mViewElement); 

    return mView; 
} 

Oto item_critere.xml z SeekBar

Oto mój kod

Odpowiedz

28

Wystarczy dodać onTouchListener. Po dotknięciu ekranu na pasku wyszukiwania (action_down) nie zezwalaj rodzicowi na przechwycenie zdarzenia.

seekbar.setOnTouchListener(new ListView.OnTouchListener() 
{ 
    @Override 
    public boolean onTouch(View v, MotionEvent event) 
    { 
     int action = event.getAction(); 
     switch (action) 
     { 
     case MotionEvent.ACTION_DOWN: 
      // Disallow Drawer to intercept touch events. 
      v.getParent().requestDisallowInterceptTouchEvent(true); 
      break; 

     case MotionEvent.ACTION_UP: 
      // Allow Drawer to intercept touch events. 
      v.getParent().requestDisallowInterceptTouchEvent(false); 
      break; 
     } 

     // Handle seekbar touch events. 
     v.onTouchEvent(event); 
     return true; 
    } 
}); 
+0

Wow, to działa tak dobrze! Dzięki :) – nsvir

+0

To zostało faktycznie skopiowane do używania ListViews wewnątrz ScrollView. Tak więc jest to nowy SeekBar.OnTouchListener zamiast ListView.onTouchListener. To naprawdę prosty sposób i działa na wiele tego rodzaju problemów. – dumazy

+0

Teraz trudniej .. x) Dodałem przewijanie między szufladą nawigacyjną a panelem wyszukiwania. Chcę tylko wyłączyć zdarzenie interceptTouch z szuflady nawigacji, a nie widok przewijania x) Czy to możliwe? – nsvir

Powiązane problemy