西米啊 2017-09-21 02:17
浏览 1918

android中用tabLayout写底部导航栏时切换按钮时只切换布局,布局对应的活动没反应

public class Fragment1 extends Fragment {
private LuckyPanView mLuckyPanView;
private ImageView mStartBtn;
@Nullable
@Override

public View onCreateView(LayoutInflater inflater,
                         @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment1, container, false);

    mLuckyPanView = (LuckyPanView) rootView.findViewById(R.id.id_luckypan);
    mStartBtn = (ImageView) rootView.findViewById(R.id.id_start_btn);

    return inflater.inflate(R.layout.fragment1,container, false);
}

public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Log.d("string","123");
            //抽奖转盘的开始按钮的点击事件
    mStartBtn.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)
        {
            int count = Integer.valueOf((int)(Math.random()*1000));
            //int count = 1;
            if (!mLuckyPanView.isStart())
            {
                //当index为0的时候停在"单反"的位置,当index为1的时候停在"ipad"的位置,
                // 当index为-1和2的时候停在"恭喜发财"的位置,当index为3的时候停在"iphone"的位置
                //当index为4的时候停在"服装一套"的位置
                Log.d("int","444444444");
                if(count==1){
                    mLuckyPanView.luckyStart(1);
                }else if(count>=2 && count<=3){
                    mLuckyPanView.luckyStart(0);
                }else if(count>=4 && count<=8){
                    mLuckyPanView.luckyStart(3);
                }else if(count>=9 && count<=28){
                    mLuckyPanView.luckyStart(4);
                }else if(count>=29 && count<=500){
                    mLuckyPanView.luckyStart(2);
                }else if(count>=500 && count<=1000){
                    mLuckyPanView.luckyStart(-1);
                }
                mStartBtn.setImageResource(R.drawable.stop);
            } else
            {
                if (!mLuckyPanView.isShouldEnd())

                {
                    mLuckyPanView.luckyEnd();
                    mStartBtn.setImageResource(R.drawable.start);
                }
            }
        }
    });


}

}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 链接问题 C++LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题
    • ¥15 Python时间序列如何拟合疏系数模型
    • ¥15 求学软件的前人们指明方向🥺
    • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接