android - How to hide the whole RecyclerView? -
i trying hide recyclerview
until user passes valid information. not happening. weird things happen when try doesn't show error.
here's code:
mainactivity.java
public class mainactivity extends appcompatactivity { private toolbar toolbar; private linearlayout recyclerrow; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); paper.init(getapplicationcontext()); toolbar = (toolbar) findviewbyid(r.id.app_bar); setsupportactionbar(toolbar); getsupportactionbar().setdisplayshowhomeenabled(true); navigationdrawerfragment drawerfragment = (navigationdrawerfragment) getsupportfragmentmanager().findfragmentbyid(r.id.fragment_navigation_drawer); drawerfragment.setup(r.id.fragment_navigation_drawer, (drawerlayout) findviewbyid(r.id.drawer_layout), (toolbar) findviewbyid(r.id.app_bar)); recyclerview recyclerview = (recyclerview) findviewbyid(r.id.goallist); rvadapter adapter = new rvadapter(getapplicationcontext(), getdata()); recyclerview.setadapter(adapter); recyclerview.setlayoutmanager(new linearlayoutmanager(getapplicationcontext())); recyclerrow = (linearlayout) findviewbyid(r.id.goal_row); if(paper.get("goaltitle") == null){ recyclerview.setvisibility(view.gone); recyclerrow.setvisibility(view.gone); } } public list<rvdata> getdata() { log.d("check6", paper.get("goaltitle") + ""); list<rvdata> data = new arraylist<>(); string[] titles = {(string) paper.get("goaltitle")}; (int = 0; < titles.length; i++) { rvdata current = new rvdata(); current.goaltitle = titles[i]; data.add(current); } return data; } public void newgoal(view view) { intent intent = new intent(mainactivity.this, newgoal.class); startactivity(intent); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } }
i using paper database.
instead of setvisibility, can use setalpha(0)
hide , setalpha(1)
show. ended doing. quite working well. same effect if use visibility invisible
.
Comments
Post a Comment