[英]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.我正在制作一个 ui 门户。 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 { '''公共类 MainActivity 扩展 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
您可以为每个人定义一些代码,例如学生 1 和老师 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
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.