0

A user inputs a word...The word is placed in an array-string when the OK button is pressed...I..if the user inputs a word with a blank letter(corresponded by a space) example "h" "_" "l" "l" "o" (the second letter is a space),the blank/space will display a toast to instruct user to choose a letter from a spinner that will replace the blank...When the letter is chosen and the submit button is pressed (in this example "e" was chosen)the completed word will be displayed at the TextView (which is "hello")...How do i do this?..the replacing of the 'space' to a 'letter' from the spinner...thanks

the code that i have..[it's just for the input of word in edittext and output on textview...]

public class MainActivity extends Activity {

private Spinner spinner1;
private Button btnsubmit; 

TextView wordview;
    EditText theword;
    Button btnok;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    wordview = (TextView) findViewById (R.id.textView1);
    theword = (EditText) findViewById(R.id.inputtext);
    btnok = (Button) findViewById(R.id.btnok);

    btnok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String thewordcontent = theword.getText().toString();

            wordview.setText("the word is:" + thewordcontent);

        }
    });


    addListenerOnButton ();
    addListenerOnSpinnerItemSelection ();

}

public void addListenerOnSpinnerItemSelection() {
    spinner1 = (Spinner) findViewById(R.id.spinner1);
    spinner1.setOnItemSelectedListener(new CustomItemListener());
  }

 public void addListenerOnButton() {

     spinner1 = (Spinner) findViewById(R.id.spinner1);

     btnsubmit = (Button) findViewById (R.id.btnsubmit);
     btnsubmit.setOnClickListener(new OnClickListener() {


          public void onClick(View v) {
            Toast.makeText(MainActivity.this,
            "OnClickListener : " + 
                    "\nSpinner 1 : "+ String.valueOf(spinner1.getSelectedItem()) ,
                Toast.LENGTH_SHORT).show();
          }

        });
      }


}
4

0 回答 0