myTextview,myButton是在fragment_main.xml中的,在没引进fragment_main.xml之前,你是通过findViewById找不到的。。,所以要在onCreateView中引入。
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {

在Android开发中,遇到在onCreate方法里通过findViewByid无法获取到activity_main.xml布局文件中定义的R.id.view的问题。通常这个问题可能由于布局文件未正确加载或者资源ID不存在导致。
最低0.47元/天 解锁文章
5344

被折叠的 条评论
为什么被折叠?



