I'm having issues with my listFragment staying in the middle of the page. Like this:
I'm using a listview in my xml document like this
<?xml version="1.0" encoding="utf-8"?>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@android:id/list"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
Which i'm pretty sure has no issues. But my Java i'm guessing is a little more dubious as i'm still learning.
public class menu_4_fragment extends ListFragment implements AdapterView.OnItemClickListener {
View rootview;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Basic way of implementing title, perhaps a better method should be used if found
getActivity().getActionBar().setTitle("Settings");
rootview = inflater.inflate(R.layout.menu4_layout, container, false);
return rootview;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Brings the data from XML to view
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.Settings_strings, android.R.layout.simple_list_item_1);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
Can you guys see anything that's potential causing this issue? Or perhaps what would be a better way to implement this list frag? I'm having a bit of an issue implementing this in the first place as i've already got a fragmentation from my navigation drawer and most tutorials don't show how to implement a listview beyond that.
Thanks guys.
Aucun commentaire:
Enregistrer un commentaire