Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个问题,我必须将字符串的值从主类调用到辅助类,我如何才能从第二类访问主类上的字符串?我有第一类(LoginActivity)和第二类(DashboardActivity)我必须在仪表板中获取LoginActivity(字符串用户名)的返回值,我该怎么做?
启动 DashboardActivity 时,将字符串值作为 Intent.EXTRA 传递。
启动时:
Intent i = new Intent(getBaseContext(), DashboardActivity.class); i.putExtra("MyString", username);
并获得价值:
Bundle bundle = getIntent().getExtras(); String value = bundle.getString("MyString");