I try to make an app that the user can make tabs but it seems not to work , I get an error "Invalid int: "" "
If you know how to make it that the user can make unlimited tabs that would be great.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mDrawerListView = (ListView) inflater.inflate(
R.layout.fragment_navigation_drawer, container, false);
mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
}
});
TabRepo repo = new TabRepo(getActivity());
Tab tab = new Tab();
// If the tab is null or "" make one
if(repo.getTabList().get(0).get(Tab.KEY_name) == null||repo.getTabList().get(0).get(Tab.KEY_name) == ""){
tab.age= 1;
tab.url="";
tab.name="";
tab.tab_ID= 0;
repo.insert(tab);
}
if(repo.getTabList().get(1).get(Tab.KEY_name) == null||repo.getTabList().get(1).get(Tab.KEY_name) == ""){
tab.age= 1;
tab.url="";
tab.name="";
tab.tab_ID= 0;
repo.insert(tab);
}
if(repo.getTabList().get(2).get(Tab.KEY_name) == null||repo.getTabList().get(2).get(Tab.KEY_name) == ""){
tab.age= 1;
tab.url="";
tab.name="";
tab.tab_ID= 0;
repo.insert(tab);
}
if(repo.getTabList().get(3).get(Tab.KEY_name) == null||repo.getTabList().get(3).get(Tab.KEY_name) == ""){
tab.age= 1;
tab.url="";
tab.name="";
tab.tab_ID= 0;
repo.insert(tab);
}
if(repo.getTabList().get(4).get(Tab.KEY_name) == null||repo.getTabList().get(4).get(Tab.KEY_name) == ""){
tab.age= 1;
tab.url="";
tab.name="";
tab.tab_ID= 0;
repo.insert(tab);
}
mDrawerListView.setAdapter(new ArrayAdapter<>(
getActionBar().getThemedContext(),
android.R.layout.simple_list_item_activated_1,
android.R.id.text1,
new String[]{
// add all the strings
getString(R.string.title_section1),
getString(R.string.title_section2),
getString(R.string.title_section3),
getString(R.string.title_section4),
getString(R.string.title_section5),
repo.getTabList().get(0).get(Tab.KEY_name),
repo.getTabList().get(1).get(Tab.KEY_name),
repo.getTabList().get(2).get(Tab.KEY_name),
repo.getTabList().get(3).get(Tab.KEY_name),
repo.getTabList().get(4).get(Tab.KEY_name),
}
));
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
return mDrawerListView;
}
I hope you can help me .
Aucun commentaire:
Enregistrer un commentaire