小编roh*_*hiH的帖子

如何解决像java.lang.Throwable:setStateLocked这样的错误?

我正在开发一个应用程序.在其中我使用listview.当我点击列表项时,它应该转到下一个活动,即ProfileActivity2.java.它工作正常,但在这个ProfileActivty2底部有一个按钮,当我点击这个按钮时,我的应用程序崩溃并停在listview页面中.并在listview布局文件中显示错误java.lang.Throwable:setStateLocked,即atSetContentView.我该如何解决这个错误?

//ProfileActivity2.java

    public class ProfileActivity2 extends AppCompatActivity {

        //Textview to show currently logged in user
        private TextView textView;
        private boolean loggedIn = false;
        Button btn;
        EditText edname,edaddress;

        TextView tvsname, tvsprice;
        NumberPicker numberPicker;
        TextView textview1,textview2;
        Integer temp;
        String pname, paddress, email, sname, sprice;


        @Override
        protected void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_profile1);

            //Initializing textview
            textView = (TextView) findViewById(R.id.textView);
            edname=(EditText)findViewById(R.id.ed_pname);
            edaddress=(EditText)findViewById(R.id.ed_add);
            tvsname=(TextView)findViewById(R.id.textView_name);
            tvsprice=(TextView)findViewById(R.id.textView2_price);
            btn=(Button)findViewById(R.id.button);

            Intent i = getIntent();
            // getting attached intent data
            String name = i.getStringExtra("sname");
            // displaying selected product name
            tvsname.setText(name);

            String …
Run Code Online (Sandbox Code Playgroud)

java android listview android-activity

5
推荐指数
1
解决办法
5483
查看次数

标签 统计

android ×1

android-activity ×1

java ×1

listview ×1