How do I start other activities through Intent in a custom component?

I have customized a component ButtomHurdle, that has buttons, and I want to start other activities through buttons, but the ButtomHurdle class does not inherit the Activity class, so I cannot use the startActivity method to start other classes. When I listen to the button, I try to use view.getContext () to call startActivity,. Although the compilation is successful, clicking the button still does not respond.
public void onClick (View view) {

    switch (view.getId()){
        case R.id.bottom :
            intent = new Intent(view.getContext(), CateGory.class);
            view.getContext().startActivity(intent);
    }

}
how do I start other activities through Intent in custom components?

Mar.07,2021

you just throw the button events in your own custom component to the activity interface to handle.


the description of the problem is not very clear. you have not told me whether it is the problem with this code or your related click monitoring event . If it is confirmed that it is the problem with this code Intent, then the upstairs zzxxasp is feasible.

but in fact, after my simple test,

intent = new Intent(view.getContext(), CateGory.class);
view.getContext().startActivity(intent);

there is no problem. It can be used and run normally. Please test back

.

Custom button writes an entry, passes the context of Activity to view
or view write listening method, and implements the jump function in Activity

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c0ab-2c2ed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c0ab-2c2ed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?