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

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 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题