Hi guys Since am new to android. I am having some problem. I am - TopicsExpress



          

Hi guys Since am new to android. I am having some problem. I am not able to register for a course using sqlite database with spinner, radio button and text view. Could you plz help me. Here is my work: package com.example.shalini1.mobileapplication; import android.app.Activity; import android.os.Bundle; import android.widget.RadioButton; import android.widget.Spinner; import android.widget.ArrayAdapter; import android.widget.AdapterView; import android.view.View; import android.widget.Toast; public class CourseActivity extends Activity { Spinner course, semester; String[] course_name={ Bsc-Investment and analysis, Bsc-Banking and financial services, Bsc-Accounting and finance, Bsc-Marketing, Bsc-Human Resource Management, Bsc-Retail Marketing, Bsc-Software Engineering, LP-Networking and Database Management, LP-Multimedia }; String[] semester_course={ 1, 2, 3, 4, 5, 6, }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_course); course = (Spinner) findViewById(R.id.spinnerCoursename); semester = (Spinner) findViewById(R.id.spinnerSemester); ArrayAdapter adapter = new ArrayAdapter( this, android.R.layout.simple_spinner_item, course_name); course.setAdapter(adapter); ArrayAdapter adapter1 = new ArrayAdapter( this, android.R.layout.simple_spinner_item, semester_course); semester.setAdapter(adapter1); course.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { int position = course.getSelectedItemPosition(); Toast.makeText(getApplicationContext(), You have selected + course_name[+position], Toast.LENGTH_LONG).show(); // TODO Auto-generated method stub } @Override public void onNothingSelected(AdapterView arg0) { // TODO Auto-generated method stub } } ); semester.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { int position = semester.getSelectedItemPosition(); Toast.makeText(getApplicationContext(), You have selected + semester_course[+position], Toast.LENGTH_LONG).show(); // TODO Auto-generated method stub } @Override public void onNothingSelected(AdapterView arg0) { // TODO Auto-generated method stub } } ); } // Event handler for radio buttons public void onRadioButtonClicked(View view) { // Is the button now checked? boolean checked = ((RadioButton) view).isChecked(); // Check which radio button was clicked switch(view.getId()) { case R.id.rbIT: if (checked) Toast.makeText(this, Youve selected: Department Of Information Technology, Toast.LENGTH_LONG).show(); break; case R.id.rbBA: if (checked) Toast.makeText(this, Youve selected: Department Of Business Administration, Toast.LENGTH_LONG).show(); break; } } }
Posted on: Sun, 16 Nov 2014 15:15:26 +0000

Trending Topics



Recently Viewed Topics




© 2015