2012-12-22 12 views
9

काट दिया गया है मेरे पास एक चेतावनी संवाद है जो कोई विशिष्ट बटन छूता है जब प्रारंभ होता है। अलर्ट संवाद में एक दृश्य होता है जिसे लेआउट xml फ़ाइल द्वारा परिभाषित किया जाता है। इस लेआउट में चेक बॉक्स जैसे कई नियंत्रण हैं, टेक्स्ट फ़ील्ड संपादित करें, ... ये नियंत्रण सभी स्क्रोल दृश्य के अंदर हैं ताकि आप सामग्री के माध्यम से स्क्रॉल कर सकें, अगर पूरी सामग्री स्क्रीन पर फिट नहीं होती है।चेतावनी संवाद के बटन

समस्या यह है कि जब मैं इस चेतावनी संवाद को शुरू करता हूं, तो नीचे दिए गए बटन स्क्रीन को काटते हैं। Altro स्क्रोल बार काम कर रहा है और मैं अलर्ट संवाद की सामग्री के माध्यम से स्क्रॉल कर सकते हैं, चेतावनी संवाद के बटन कभी-कभी पूरी तरह से दिखाई नहीं दे रहे हैं।

इसका मतलब है: कभी-कभी, सब ठीक है और मैं चेतावनी संवाद के बटन देख सकता हूं, कभी-कभी अजीब कारण के लिए, बटन काट दिया जाता है। मुझे लगता है कि यह चेतावनी संवाद के लिए बड़ा होने और बटन को और नीचे दबाकर देखने का मुद्दा है। उदाहरण के लिए, दृश्य में एक संपादन टेक्स्ट नियंत्रण होता है। अगर मैं अपना नाम थर डालता हूं, तो सब कुछ ठीक है। लेकिन अगर मैं इस संपादन टेक्स्ट में एक नई लाइन जोड़ता हूं, तो बटन थोड़ा सा कटौती शुरू हो जाते हैं। मैंने क्या गलत किया? मैंने सोचा था कि स्क्रॉल व्यू मेरे दृश्य के oversize को संभालेगा ताकि चेतावनी संवाद स्क्रीन पर फिट हो। मेरा ऐप हमेशा पोर्ट्रेट मोड में है।

देखने का कोड:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:padding="5dp" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/bitteeinstellungenwaehlen" /> 

     <EditText 
      android:id="@+id/edtTeam1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:hint="@string/hteam1" 
      android:text="Christoph" > 

      <requestFocus /> 
     </EditText> 

     <EditText 
      android:id="@+id/edtTeam2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:hint="@string/hteam2" 
      android:text="Lea" /> 

     <EditText 
      android:id="@+id/edtTeam3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:hint="@string/hteam3" 
      android:text="Ludwig" /> 

     <EditText 
      android:id="@+id/edtTeam4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:hint="@string/hteam4" 
      android:text="Anja" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/weitereeinstellungen" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <CheckBox 
       android:id="@+id/chkModerationMode" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/moderationsmodus" /> 

      <TextView 
       android:id="@+id/textView3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:text="@string/info" /> 

     </LinearLayout> 

     <CheckBox 
      android:id="@+id/chkPassOver" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:text="@string/weitergeben" /> 

     <CheckBox 
      android:id="@+id/chkBlackScreen" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/blankscreen" /> 

    </LinearLayout> 

</ScrollView> 

और इस तरह मैं चेतावनी संवाद प्रारंभ करें:

final AlertDialog.Builder alert = new AlertDialog.Builder(QuizEditor.this); 

    alert.setTitle(getString(R.string.speichernUndVorschau) + "..."); 
    alert.setMessage(""); 


    LayoutInflater inflater = LayoutInflater.from(QuizEditor.this); 
    final View layFrage = inflater.inflate(R.layout.layoutquizsettings,null); 
    alert.setView(layFrage); 

    final CheckBox chkModeration = (CheckBox) layFrage.findViewById(R.id.chkModerationMode); 
    final CheckBox chkPassOver = (CheckBox) layFrage.findViewById(R.id.chkPassOver); 
    final CheckBox chkBlackScreen = (CheckBox) layFrage.findViewById(R.id.chkBlackScreen); 

    final EditText edtTeam1 = (EditText) layFrage.findViewById(R.id.edtTeam1); 
    final EditText edtTeam2 = (EditText) layFrage.findViewById(R.id.edtTeam2); 
    final EditText edtTeam3 = (EditText) layFrage.findViewById(R.id.edtTeam3); 
    final EditText edtTeam4 = (EditText) layFrage.findViewById(R.id.edtTeam4); 



    alert.setNeutralButton(getString(R.string.speichernUndVorschau), new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int whichButton) { 




    } 
    }); 

    alert.setNegativeButton(getString(R.string.abbrechen), new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int whichButton) { 
     // Canceled. 
     } 
    }); 



    final AlertDialog dialog2 = alert.create(); 

    dialog2.setOnShowListener(new OnShowListener() { 

     @Override 
     public void onShow(DialogInterface dialog) { 
      // TODO Auto-generated method stub 
      Button btnStarten = (Button) dialog2.getButton(AlertDialog.BUTTON_NEUTRAL); 
      btnStarten.setOnClickListener(new OnClickListener() { 

       @Override 
       public void onClick(View v) { 
        // TODO Auto-generated method stub 
        ArrayList<String> teams = new ArrayList<String>(); 

        String team1 = edtTeam1.getText().toString().trim(); 
        String team2 = edtTeam2.getText().toString().trim(); 
        String team3 = edtTeam3.getText().toString().trim(); 
        String team4 = edtTeam4.getText().toString().trim(); 

        if(team1.length() > 0) teams.add(team1); 
        if(team2.length() > 0) teams.add(team2); 
        if(team3.length() > 0) teams.add(team3); 
        if(team4.length() > 0) teams.add(team4); 

        if(teams.size() == 0) { 
         Toast.makeText(QuizEditor.this, getString(R.string.keinteameingegeben), Toast.LENGTH_SHORT).show(); 

        } 
        else 
        { 
         // Quiz starten 



         dialog2.dismiss(); 
         Intent myIntent; 

         if(chkBlackScreen.isChecked()) { 
          myIntent = new Intent(QuizEditor.this, BlackScreen.class); 
         } 
         else // Direkt das Quiz starten 
         { 
          myIntent = new Intent(QuizEditor.this, Quiz.class); 
         } 


         myIntent.putStringArrayListExtra("teams", teams); 
         myIntent.putExtra("moderation", chkModeration.isChecked()); 
         myIntent.putExtra("passover", chkPassOver.isChecked()); 
         myIntent.putExtra("filename", filename); 


         QuizEditor.this.startActivity(myIntent); 
        } 
       } 

      }); 

     } 

    }); 

    dialog2.show(); 
    // dialog2.getWindow().setLayout(LayoutParams.WRAP_CONTENT, 300); 

मैं जर्मन शब्दों के लिए माफी चाहता हूँ। छवि में आप समस्या देख सकते हैं। दुर्भाग्य से मुझे बनाए गए स्क्रीनशॉट अपलोड करने की अनुमति नहीं थी ...

+2

आपकी मदद के लिए ठीक है धन्यवाद! सौभाग्य से, मुझे mistakte मिला: alert.setMessage (""); चूंकि मैंने इस पंक्ति को हटा दिया है, तो सभी ठीक काम करते हैं। इस समाधान के लिए – Chris623

+0

वही है। Komischer fehler und schwer zu finden danke dafür =) –

उत्तर

0

संपादन टेक्स्ट लाइनों को 1 पर सेट करें। बाहरी लाइनरलाउट को fill_parent पर भी सेट करें।

0

बस सभी EditText संपत्ति android:singleLine="true" बनाएं और फिर परीक्षण करने का प्रयास करें।

0

प्रश्नों में प्रश्न पहले ही हल हो चुका था, लेकिन मैं पूर्णता के लिए एक जवाब जोड़ूंगा और यह दिखाने के लिए कि यह मेरे लिए भी काम करता है।

कस्टम दृश्य के साथ AlertDialog के लिए, .setMessage लाइन का उपयोग न करें। मेरे प्रोजेक्ट में निम्न पंक्ति को हटाने से बटन बंद हो जाते हैं।

.setMessage("This is my message") 
संबंधित मुद्दे