简体   繁体   English

我想制作一个点击监听器,当我从下拉菜单中选择一个项目时,它会转到 android studio 中的所需页面

[英]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.

相关问题 硒驱动器-从下拉列表中选择所需的锂项目 - Selenium driver - select the desired li item from a drop down list 当我单击列表视图(android studio)中的项目时,如何创建要显示的弹出菜单? - How can I create a popup menu to be shown when I click on an item in listview(android studio)? 单击一个按钮,将启动一个弹出菜单,然后单击一个弹出菜单项,然后所选项目将显示在 android 工作室的按钮文本上 - click on a button, a popup menu will start, and then I click on a popup menu item then selected item will show on buttontext in android studio 无法从特定的下拉菜单中选择项目(文本)? - Unable to select item (Text) from a specific drop down menu? 单击项目时,使ActionBar上的菜单保持打开状态 - Make menu on ActionBar stay open when I click on an item 如何使我的变量=下拉菜单中的项目 - How to make my variable = the item from the Drop Down Menu 我想从组合框中选择一个项目,然后单击按钮时根据所选项目打开另一个框架 - i want select an item from the combo box and open another frame according to the selected item when I click a button 在android Studio中,我想要当我单击按钮时,下一个活动/片段应该来自右侧 - In android Studio, I want when i click on button , next activity/fragment should come from right side 单击时Android无法显示菜单下拉菜单 - Android cannot show menu drop down when click 我如何在硒的帮助下单击此下拉菜单? - How can I click on this drop-down menu with help of selenium?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM