第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何修復此按鈕,它無法轉到活動頁面?

如何修復此按鈕,它無法轉到活動頁面?

瀟瀟雨雨 2022-08-03 15:39:20
public class select_fragment extends Fragment {    @Nullable    @Override    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {        return inflater.inflate(R.layout.fragment_select, null);    }    private void button_parking(){        Intent myIntent = new Intent(f, parking.class);        startActivity(myIntent);    }}
查看完整描述

2 回答

?
手掌心

TA貢獻1942條經驗 獲得超3個贊

試試這個...


public class select_fragment extends Fragment {


@Nullable

@Override

public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup 

container, @Nullable Bundle savedInstanceState) {


    Button your_button = (Button) getActivity.findViewById(R.id.your_id_button)


    your_button.setOnClickListener(new OnClickListener() {

    public void onClick(View v)

    {

       button_parking();

    } 

    });

    return inflater.inflate(R.layout.fragment_select, null);


    }


    private void button_parking(){

    Intent myIntent = new Intent(getActivity(), parking.class);

    startActivity(myIntent);

}

}


查看完整回答
反對 回復 2022-08-03
?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

您尚未將視圖綁定到片段,因此單擊按鈕無法正常工作。您需要使用 綁定視圖。通常,您需要通過重寫如下內容來執(zhí)行綁定:findViewById()onViewCreated()


public class select_fragment extends Fragment {


    @Nullable

    @Override

    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_select, null);

    }


    @Override

    public void onViewCreated(View view, Bundle savedInstanceState) {

        super.onViewCreated(view, savedInstanceState);


         // bind the view here.

         Button button = findViewById(R.id.your_button);

         button.setOnClickListener(new View.OnClickListener() {

             public void onClick(View v) {

                 //call button method here

                 button_parking();

             }

         });

    }


    private void button_parking() {

        Intent myIntent = new Intent(f, parking.class);

        startActivity(myIntent);

    }

}


查看完整回答
反對 回復 2022-08-03
  • 2 回答
  • 0 關注
  • 91 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號