首先,我是Android编程的新手,所以请放轻松我,并提前感谢。所以我有一个简单的,两个活动的Android博客应用程序。我在一个活动中创建博客并在另一个活动中显示它们。首先,每个博客都有相同的标题和作者,但用户可以插入内容。当我插入内容时,一切似乎都很好。然而,当我正在加载博客标题显示正常并且内容保持空白时,任何人都可以帮助我吗?
这是加载代码:
class A
{
int a;
double b;
public:
A(){a=20;B=78.438;}
void data()
{ int num1; num1=a;}
}
这是上传代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Button loadButton = (Button) findViewById(R.id.loadButton);
final TextView titleDisplay = (TextView) findViewById(R.id.titleLoadDisplay);
final TextView contentDisplay = (TextView) findViewById(R.id.contentLoadDisplay);
BlogDbHelper dbHelper = new BlogDbHelper(getApplicationContext());
final SQLiteDatabase db = dbHelper.getReadableDatabase();
//What I will use after the query
final String[] projection = {
BlogContract.BlogEntry.BLOG_TITLE,
BlogContract.BlogEntry.BLOG_CONTENT
};
if (loadButton != null) {
loadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Cursor res = db.query(
BlogContract.BlogEntry.TABLE_NAME,
projection,
null,
null,
null,
null,
null
);
res.moveToFirst();
if (titleDisplay != null) {
titleDisplay.setText(res.getString(res.getColumnIndex(BlogContract.BlogEntry.BLOG_TITLE)));
}
if (contentDisplay != null) {
contentDisplay.setText(res.getString(res.getColumnIndex(BlogContract.BlogEntry.BLOG_CONTENT)));
}
}
});
}
// blogList.setAdapter(adapter);
}