如何在导航抽屉类中使用另一个活动元素?

时间:2017-10-01 03:03:55

标签: android android-studio button android-activity click

我正在使用导航抽屉活动。所以活动没有上课。只有布局。导航抽屉只有班级。所以我想在那个类中编写一个代码。我正在使用按钮,但应用程序在启动导航活动时不工作。请帮帮我。



public class ProfileActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    
    FragmentManager mfragementManger;
    Button BTNeditprofile;
    EditText ETprofilename;
    




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);


        
        BTNeditprofile = (Button)findViewById(R.id.BTNeditprofile);
        ETprofilename = (EditText)findViewById(R.id.ETprofilename);

        BTNeditprofile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                
            }
        });




这是其他活动元素。 当我编写一个代码来点击时,运行后得到错误



BTNeditprofile = (Button)findViewById(R.id.BTNeditprofile);
        ETprofilename = (EditText)findViewById(R.id.ETprofilename);

        BTNeditprofile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                
            }
        });




0 个答案:

没有答案