有人可以告诉我是什么错误 enter image description here
这是我的代码
package com.andisofttechnology.myapplication.Model;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v7.app.AppCompatActivity;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.andisofttechnology.myapplication.Common.Common;
import com.andisofttechnology.myapplication.Interface.ItemClickListener;
import com.andisofttechnology.myapplication.R;
import com.andisofttechnology.myapplication.ViewHolder.MenuViewHolder;
import com.andisofttechnology.myapplication.model.Category;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
import java.util.Locale;
public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
FirebaseDatabase database;
DatabaseReference category;
TextView txtFullName;
RecyclerView recycler_menu;
LinearLayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Menu");
setSupportActionBar(toolbar);
//Init Firebase
database = FirebaseDatabase.getInstance();
category = database.getReference("Category");
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
//Set Name for User
View headerView = navigationView.getHeaderView(0);
txtFullName = (TextView)findViewById(R.id.txtFullname);
txtFullName.setText(Common.currentUser.getName());
//Load Menu
recycler_menu = (RecyclerView)findViewById(R.id.recycler_menu);
recycler_menu.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recycler_menu.setLayoutManager(layoutManager);
loadMenu();
}
private void loadMenu() {
FirebaseRecyclerOptions<Category> options =
new FirebaseRecyclerOptions.Builder<Category>()
.setQuery(MenuViewHolder, Category.class)
.build();
FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<Category, MenuViewHolder>(Category.class,R.layout.menu_item,MenuViewHolder.class,category) {
Brother, [07.09.18 01:16]
@Override
public MenuViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.menu_item, parent, false);
return new MenuViewHolder(view);
}
@Override
protected void onBindViewHolder(MenuViewHolder holder, int position, Category model) {
holder.txtMenuName.setText(model.getName());
Picasso.with(getBaseContext()).load(model.getName()).into(holder.imageView);
final Category clickItem = model;
holder.setItemClickListener(new ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick) {
Toast.makeText(Home.this, ""+clickItem.getName(),Toast.LENGTH_SHORT).show();
}
});
}
};
recycler_menu.setAdapter(adapter);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
/* if (id == R.id.action_settings) {
return true;
}*/
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
/* if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}*/
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.andisofttechnology.myapplication"
minSdkVersion 16
buildToolsVersion "27.0.1"
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.android.support:design:26.1.0'
testCompile 'junit:junit:4.12'
//Add Library
compile 'com.firebaseui:firebase-ui-auth:3.3.1'
compile 'com.google.firebase:firebase-core:16.0.1'
compile 'com.google.firebase:firebase-database:16.0.1'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.firebaseui:firebase-ui-database:3.3.1'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.squareup.picasso:picasso:2.5.2'
有人可以告诉该特定行中有什么错误吗.................................... ................................................... ................................................... ................................................... .....
答案 0 :(得分:1)
您已经在使用for example:
i have a folder contain:
usa.tif (1 pages)
england.tif (2 page)
brazil.tif (3 pages)
egypt.tif (4 pages)
france.tif (5 pages)
xxxxx.tif (x pages)
i want to add or append flag.png as a page to the end each tif image above
so output will be like this:
usa.tif ( 2 pages )
england.tif ( 3 pages )
brazil.tif ( 4 pages )
egypt.tif ( 5 pages )
france.tif ( 6 pages )
xxxxx.tif (x+1 pages)
:
FirebaseRecyclerOptions
构造函数 FirebaseRecyclerOptions<Category> options =
new FirebaseRecyclerOptions.Builder<Category>()
.setQuery(MenuViewHolder, Category.class)
.build();
采用一种FirebaseRecyclerAdapter
类型的变量,如下所示:
更改此:
FirebaseRecyclerOptions
对此:
FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<Category, MenuViewHolder>(Category.class,R.layout.menu_item,MenuViewHolder.class,category) {
答案 1 :(得分:0)
您需要像这样实现FirebaseRecyclerAdapter:
FirebaseRecyclerAdapter<YourModel, YourModelViewHolder> firebaseUsersAdapter = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseRecyclerOptions<YourModel> options = new FirebaseRecyclerOptions.Builder<YourModel>()
.setQuery(query, YourModel.class)
.build();
firebaseUsersAdapter = new FirebaseRecyclerAdapter<YourModel, YourModelViewHolder>(
options) {
@Override
protected void onBindViewHolder(YourModelViewHolder holder, int position, Users model) {
holder.name.setText(model.getName());
...
}
@Override
public YourModelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.R.layout.menu_item, parent, false);
return new YourModelViewHolder(view);
}
};
mAllUsersRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAllUsersRecyclerView.setAdapter(firebaseUsersAdapter);
firebaseUsersAdapter.startListening();
希望对您有帮助。