该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
android开发过程中,我在Fragmet里写一个记事本,作为一个功能
按照网上的例子,建立三个类,NoteDateBaseHelper,noteEdit ,MainActivity
MainActivity是主页面,是显示item内容,noteEdit 是编辑页面
在MainActivity跳转到noteEdit失败,我试了一下,是noteEdit类的问题,一个一个测试的
************************************************************************************
private NoteDateBaseHelper DBHelper;
public int enter_state = 0;//用来区分是新建一个note还是更改原来的note
public String last_content;//用来获取edittext内
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.diary_edit);
InitView();
}
private void InitView() {
.........
..........
//获取此时时刻时间
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String dateString = sdf.format(date);
tv_date.setText(dateString)
//接收内容和id
Bundle mybundle = this.getIntent().getExtras();***********************************************
last_content1 = mybundle.getString("info") ;**************************************************
enter_state1 = mybundle.getInt("enter_state");*************************************************
et_content.setText(last_content1);
btn_cancel.setOnClickListener(this);
btn_ok.setOnClickListener(this);
}
@Override
public void onClick(View view) {
*******************************************************************************
关键是 last_content = mybundle.getString("info") ;**************************************************
enter_state= mybundle.getInt("enter_state");***********************************
这两行,只要有一个,这个就从MainActivity无法跳转到这个页面,注释掉这个内容就可以BUTTON,
少了这两行,点击保存之后,再点list回来就找不到内容,
但是我没有Fragment(没有导航栏的情况)时,可以运行,保存
不知道是什么原因!
各位大神,求教了!只要有头绪的都可以说一下拜托各位!