You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.8 KiB
55 lines
1.8 KiB
package com.example.fragment;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import com.example.smartglasses.R;
|
|
import com.example.smartglasses.databinding.FragmentDeviseBinding;
|
|
|
|
public class DeviseFragment extends Fragment {
|
|
|
|
FragmentDeviseBinding binding;
|
|
private String jumpPage;
|
|
private static final String ARG_PARAM1 = "jumpPage";
|
|
|
|
public DeviseFragment() {
|
|
// Required empty public constructor
|
|
}
|
|
|
|
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
if (getArguments() != null) {
|
|
jumpPage = getArguments().getString(ARG_PARAM1);
|
|
Log.i("devise", "onCreate: 在碎片中获得devise" + jumpPage);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
Bundle savedInstanceState) {
|
|
// Inflate the layout for this fragment
|
|
binding = FragmentDeviseBinding.inflate(inflater, container, false);
|
|
binding.cardView.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View view) {
|
|
Log.i("devise", "onClick: 我点击了");
|
|
if (jumpPage.equals("location")) {
|
|
LocationFragment fragment = new LocationFragment();
|
|
getFragmentManager().beginTransaction().replace(R.id.frag_layout, fragment).commit();
|
|
} else if (jumpPage.equals("trace")) {
|
|
TraceFragment fragment = new TraceFragment();
|
|
getFragmentManager().beginTransaction().replace(R.id.frag_layout, fragment).commit();
|
|
}
|
|
}
|
|
});
|
|
return binding.getRoot();
|
|
}
|
|
} |