Tag: android textview

为什么在Activity中访问Fragment的TextView会抛出错误

MainActivity类: /* all necessary imports */ public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { /* Other variable initialized here… */ FragOne fo; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); fo.setTextViewText(“This is added from Activity”); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, […]