里奥文 2018-02-13 11:18 采纳率: 50%
浏览 2239
已结题

Android开发,从Fragment中跳转到其他Activity后只显示空白的活动

准备实现的功能是点击售后服务后跳转到Guarantee这个类中。
public class ThirdFragment extends Fragment implements View.OnClickListener{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.third_fragment, container, false);
LinearLayout guaranteell = (LinearLayout) view.findViewById(R.id.serviceGuaranteeId);
guaranteell.setOnClickListener(this);
return view;
}
@Override
public void onClick(View view){
Intent intent = new Intent(getActivity(), Guarantee.class);
startActivity(intent);

        Guarantee.class的代码如下

```public class Guarantee extends AppCompatActivity {

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View view = inflater.inflate(R.layout.activity_guarantee, container, false);
    //setContentView(R.layout.activity_guarantee);
    return view;
}

}```

图片说明

图片说明

  • 写回答

8条回答

  • LuoBinary 2018-02-13 13:31
    关注

    你的ThirdFragment 里面的onClick方法没有指定id,用view.getId()获取之后确定是哪一个view的点击事件。

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程