我的片段存在很大问题 在第一个片段(List2)(导航抽屉)中,我有一个列表视图。但是在用户片段中,导航抽屉没有出现,请你帮我 帐户 - > List2 - >用户 Account.java
public class Account extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
.........................
public boolean onNavigationItemSelected(MenuItem item) {
FragmentManager fm = getSupportFragmentManager();
int id = item.getItemId();
if (id == R.id.nav_camera) {
fm.beginTransaction().replace(R.id.content_frame, new List1()).commit();
} else if (id == R.id.nav_gallery) {
fm.beginTransaction().replace(R.id.content_frame, new List2()).commit();
}
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
List2.java
public class List2 extends Fragment implements ListView.OnItemClickListener {
..........
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity().getApplicationContext(), User.class);
HashMap<String, String> map = (HashMap) parent.getItemAtPosition(position);
String tid = map.get("name").toString();
intent.putExtra("nom", tid);
startActivity(intent);
}
User.java
public class User extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootview = inflater.inflate(R.layout.fragment_user, container, false);
Intent intent = getActivity().getIntent();
..............
}
}
但是classe用户似乎从未使用过。为什么呢?
提前致谢