Optionsschaltflächen im Android StudioAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Optionsschaltflächen im Android Studio

Post by Anonymous »

Ich möchte eine Liste der Optionsfelder haben und nachdem ich eine ausgewählt habe und auf Weiter klicken möchte, möchte ich unterschiedliche Aktionen ausführen, je nachdem, welche Taste gedrückt wurde. Ich versuche derzeit, Text für eine Testtextansicht festzulegen, und für jedes Optionsfeld heißt es -1. < /p>

Code: Select all

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RadioButton;
import android.*;
import android.widget.RadioGroup;
import android.widget.TextView;

public class Polynomials extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

final View polyView = inflater.inflate(R.layout.fragment_poly, container, false);

//layout
RadioGroup rbg = (RadioGroup) polyView.findViewById(R.id.rBGPoly);
Button next = (Button) polyView.findViewById(R.id.polyButton);
final TextView test = (TextView) polyView.findViewById(R.id.jdtTest);
final RadioButton but1 = (RadioButton) polyView.findViewById(R.id.radioButton1);
RadioButton but2 = (RadioButton) polyView.findViewById(R.id.radioButton2);
RadioButton but3 = (RadioButton) polyView.findViewById(R.id.radioButton3);
RadioButton but4 = (RadioButton) polyView.findViewById(R.id.radioButton4);
RadioButton but5 = (RadioButton) polyView.findViewById(R.id.radioButton5);
RadioButton but6 = (RadioButton) polyView.findViewById(R.id.radioButton6);
RadioButton but7 = (RadioButton) polyView.findViewById(R.id.radioButton7);

RadioGroup g = (RadioGroup)polyView.findViewById(R.id.rBGPoly);

final int selected = g.getCheckedRadioButtonId();

next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

test.setText(""+selected);

}
});

return polyView;
}

}
< /code>

Und dies ist mein XML:  <   / p >   < b r   / >   < b r   / > < c o d e > & l t ; ? x m l   v e r s i o n = " 1 . 0 "   e n c o d i n g = " u t f - 8 " ? & g t ; < b r   / > & l t ; R e l a t i v e L a y o u t   x m l n s : a n d r o i d = " h t t p : / / s c h e m a s . a n d r o i d . c o m / a p k / r e s / a n d r o i d " < b r   / >         a n d r o i d : i d = " @ + i d / j d t t a e " < b r   / >         a n d r o i d : l a y o u t _ w i d t h = " m a t c h _ p a r e n t " < b r   / >         a n d r o i d : layout_height="match_parent"

android:orientation="vertical" >





/>

/>

/>

/>

/>

/>

/>







Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post