Lista db
Jakieś statyczne dane + Standarodwy Array Adapter
This commit is contained in:
parent
973092f7be
commit
a1ae369973
3 changed files with 54 additions and 6 deletions
|
@ -0,0 +1,29 @@
|
||||||
|
package info.nerull7.mysqlbrowser;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by nerull7 on 14.07.14.
|
||||||
|
*/
|
||||||
|
public class DatabaseAdapter extends ArrayAdapter<String>{
|
||||||
|
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
public DatabaseAdapter(Context context, int resource, String[] objects) {
|
||||||
|
super(context, resource, objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position){
|
||||||
|
String item = getItem(position);
|
||||||
|
return map.get(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasStableIds(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +1,36 @@
|
||||||
package info.nerull7.mysqlbrowser;
|
package info.nerull7.mysqlbrowser;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import info.nerull7.mysqlbrowser.db.DatabaseConnector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by nerull7 on 14.07.14.
|
* Created by nerull7 on 14.07.14.
|
||||||
*/
|
*/
|
||||||
public class DatabaseFragment extends Fragment {
|
public class DatabaseFragment extends Fragment {
|
||||||
|
ListView databasesListView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
||||||
//Inflate the layout for this fragment
|
//Inflate the layout for this fragment
|
||||||
return inflater.inflate(R.layout.fragment_database, container, false);
|
View V = inflater.inflate(R.layout.fragment_database, container, false);
|
||||||
|
databasesListView = (ListView)V.findViewById(R.id.databaseList);
|
||||||
|
setupListViewDatabase();
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListViewDatabase(){
|
||||||
|
// TODO not local constuction!!!
|
||||||
|
DatabaseConnector databaseConnector = new DatabaseConnector("FIXME","FIXME","FIXME");
|
||||||
|
ListAdapter listAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, databaseConnector.getDatabases());
|
||||||
|
databasesListView.setAdapter(listAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,12 @@
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
tools:context="info.nerull7.mysqlbrowser.DatabaseFragment">
|
tools:context="info.nerull7.mysqlbrowser.DatabaseFragment">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@string/hello_world"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:id="@+id/databaseList">
|
||||||
|
|
||||||
|
</ListView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue