我是Android应用程序中的新手。这些编码有问题。我想要的是,我想单击FragmentWeekly.java上的下一步按钮,它将转到下一页,即activity_main_details.xml。但是我在此代码中遇到了一个错误:“无法解析getTag”
下面是我在FragmentWeekly.java中的代码
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
public class FragmentWeekly extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_fragment_weekly, container, false);
Button btnnext = (Button) v.findViewById(R.id.btnDate);
btnnext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MainDetails mainDetails = new MainDetails();
FragmentManager manager = getFragmentManager();
manager.beginTransaction()
.replace(R.id.contdetail, mainDetails, mainDetails.getTag())
.commit();
}
});
return v;
}
}
这是我的activity_main_det
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/b1"
tools:context=".MainDetails">
<FrameLayout
android:id="@+id/contdetail"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation_detail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navdetails" />
</android.support.constraint.ConstraintLayout>
任何人都可以解释并帮助我解决此问题。
答案 0 :(得分:0)
使用意图启动MainDetails活动
CountVectorizer