简体   繁体   中英

I want to make an on click listner in such a way that when i select an item from drop down menu it goes to the desired page in android studio

I am making a ui portal. in that portal i want to make multiuser login system so that different people have a different login page and a different sequential page.

this is how my initial page looks like

Can someone help me in how can I make that kind of system where if i click 'student/visitor' it gives me one login page and if i click something else then it gives me a different login page.

'''public class MainActivity extends AppCompatActivity {

String[] items = {"Student/Visitor","Teacher","Administrator","Building Executive"};

AutoCompleteTextView autoCompleteTxt;

ArrayAdapter<String> adapterItems;



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

    autoCompleteTxt = findViewById(R.id.auto_complete_text);

    adapterItems = new ArrayAdapter<String>(this,R.layout.list_item,items);

    autoCompleteTxt.setAdapter(adapterItems);

    autoCompleteTxt.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String item = parent.getItemAtPosition(position).toString();
            Toast.makeText(getApplicationContext(),"Item: "+item, Toast.LENGTH_SHORT).show();
        }
    });

}

this is the code of my main activity.

So basically you want to implement profiling in the application. For that you can define the access roles likes if a student will login , he can access only those options which are defined for that. you can define some codes for each like for student 1 and for teacher 2

 autoCompleteTxt.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        String item = parent.getItemAtPosition(position).toString();
        Toast.makeText(getApplicationContext(),"Item: "+item, Toast.LENGTH_SHORT).show();
  if(position==1)
    student login ui page
    }
   else if(position==2)
    teacher login ui  pagge
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM