我在哪里添加代码?我搜索了很多答案,但无法找到在我的代码中添加的确切位置。帮我出如何将新帖子添加到recyclerview的顶部?
private void startPosting() {
mProgress.setMessage("Posting to Blog....");
final String title_val = mPostTitle.getText().toString().trim();
final String desc_val = mPostdesc.getText().toString().trim();
final String date_val=txtDate.getText().toString().trim();
if (!TextUtils.isEmpty(title_val) && !TextUtils.isEmpty(desc_val) && mImageUri != null) {
mProgress.show();
StorageReference filepath =mStorage.child("Blog_Images").child(mImageUri.getLastPathSegment());
filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
@SuppressWarnings("VisibleForTests") Uri downloadUrl = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatabase.push();
newPost.child("title").setValue(title_val);
newPost.child("desc").setValue(desc_val);
newPost.child("Date").setValue(date_val);
newPost.child("image").setValue(downloadUrl.toString());
mProgress.dismiss();
startActivity(new Intent(PostActivity.this,MainActivity.class));
}
你的问题setStackFromEnd(boolean)方法似乎并不清楚我的。也许https://stackoverflow.com/help/how-to-ask可以帮助你改善你的问题。 – Markus