2011-06-07 17 views
9

में कूदता है जब मैं अपना ऐप शुरू करता हूं, तो यह स्वचालित रूप से पहले "एडिटटेक्स्ट" -बॉक्स में कूद जाता है। मैंने स्क्रॉल बार में बनाया था।स्क्रॉलव्यू एडिटटेक्स्ट

और जब मैं स्क्रॉल बार को हटाता हूं, तो यह "एडिटटेक्स्ट" -बॉक्स में नहीं जाता है।

यह "एडिटटेक्स्ट" -बॉक्स में क्यों कूदता है? मुझे यह पसंद नहीं है कि यह उस बॉक्स में कूदता है। :/

यहाँ

कोड:

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

<TextView 
    android:id="@+id/textView1" 
    android:layout_height="wrap_content" 
    android:text="Brutto- oder Nettobetrag eingeben:" 
    android:layout_width="fill_parent"> 
</TextView> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <EditText 
      android:id="@+id/edt_betrag" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:inputType="numberDecimal"/> 

     <RadioGroup 
      android:id="@+id/rg_art" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <RadioButton 
       android:id="@+id/rb_art_netto" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Netto" 
       android:checked="true" /> 

      <RadioButton 
       android:id="@+id/rb_art_brutto" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Brutto" /> 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_height="wrap_content" 
       android:layout_width="fill_parent" 
       android:text="Prozentsatz eingeben:"> 
      </TextView> 

      <EditText 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:id="@+id/eigener_betrag" 
       android:inputType="numberDecimal"> 
      </EditText>  

     </RadioGroup> 

     <Button 
      android:id="@+id/Button01main" 
      android:text="Berechnen" 
      android:layout_height="50dip" 
      android:layout_width="fill_parent" 
      android:layout_gravity="center" android:layout_marginBottom="20dip"> 
     </Button> 

     <Button 
      android:layout_height="wrap_content" 
      android:id="@+id/zurueck" 
      android:text="Zurück" 
      android:layout_gravity="left" 
      android:layout_width="150dip"> 
     </Button> 

    </LinearLayout> 
</ScrollView> 

उत्तर

10
में जोड़ा गया

एस के लिए olve इस कार्यक्रम के साथ आप इस तरह कुछ कोड करना चाहिए।

ScrollView scroll = (ScrollView)findViewById(R.id.my_scroll); 
    scroll.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); 
    scroll.setFocusable(true); 
    scroll.setFocusableInTouchMode(true); 
    scroll.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      v.requestFocusFromTouch(); 
      return false; 
     } 
    }); 
7

मैं अपने आप को द्वारा समस्या हल:

 android:focusable="true" 
     android:focusableInTouchMode="true"> 

समस्या यह थी कि;)

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:focusable="true" 
      android:focusableInTouchMode="true">