1 回答
TA贡献1816条经验 获得超4个赞
我注意到下面评论中提到的一个主要问题。
public class SecondActivity extends AppCompatActivity {
private ListView lvContact;
private Button addBtn,dleBtn;
private PersonListAdapter adapter;
private List<Person> mPersonList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second_layout);
//Error as creating a new object mPersonList which is local to onCreate()
//Finally class variable mPersonList will be null still.
//ArrayList<Person> mPersonList = new ArrayList<Person>(); //Logical Error
//Solution: Use class variable instead of creating a new variable. So, just replace the above commented line with below one.
mPersonList = new ArrayList<Person>();
addBtn = (Button) findViewById(R.id.update);
..... continue
}
希望它能解决您的问题。
添加回答
举报