Inital commit of the new dynamic Fragment list. This fragment no longer

uses a listview or an adapter

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-05-22 21:21:56 -04:00
parent fbfc27c6a5
commit 2fdbb2e5bb
2 changed files with 43 additions and 49 deletions

View File

@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="wrap_content" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_list_contianer"
>
</LinearLayout> <LinearLayout
android:id="@+id/fragment_list_contianer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>

View File

@@ -11,19 +11,18 @@ import java.util.ArrayList;
import android.content.ContentValues; import android.content.ContentValues;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast;
import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener;
import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.R;
import com.TwentyCodes.android.LocationRinger.debug.Debug; import com.TwentyCodes.android.LocationRinger.debug.Debug;
import com.TwentyCodes.android.LocationRinger.ui.fragments.FragmentListAdaptor.Holder;
/** /**
* This fragment will be used to display a list of fragments * This fragment will be used to display a list of fragments
@@ -33,7 +32,16 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
* *
* @author ricky * @author ricky
*/ */
public class FeatureListFragment extends ListFragment { public class FeatureListFragment extends Fragment {
private static final String TAG = "FeatureListFragment";
private final ArrayList<Fragment> mFragments;
public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList<Fragment> fragments) {
super();
mFragments = fragments;
}
/** /**
* (non-Javadoc) * (non-Javadoc)
@@ -42,51 +50,35 @@ public class FeatureListFragment extends ListFragment {
* android.view.ViewGroup, android.os.Bundle) * android.view.ViewGroup, android.os.Bundle)
*/ */
@Override @Override
public View onCreateView(LayoutInflater inflator, ViewGroup container, public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle bundle) {
Bundle bundle) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return super.onCreateView(inflator, container, bundle);
}
private static final String TAG = "FeatureListFragment"; return inflator.inflate(R.layout.fragment_list_contianer, null);
private static final int DELETE_ID = 0;
private ArrayList<Fragment> mFeatures;
// private OnContentChangedListener mListener;
// private ContentValues mInfo;
// private int mIndex;
public FeatureListFragment(ContentValues info,
OnContentChangedListener listener, ArrayList<Fragment> fragments) {
super();
this.mFeatures = fragments;
// this.mInfo = info;
// this.mListener = listener;
} }
@Override @Override
public void onResume() { public void onResume() {
this.setListAdapter(new FragmentListAdaptor(this, mFeatures));
this.getListView().setOnCreateContextMenuListener(this);
if (Debug.DEBUG) if (Debug.DEBUG)
Log.v(TAG, "onResume()"); Log.v(TAG, "onResume()");
loadFragments();
super.onResume(); super.onResume();
} }
public void onCreateContextMenu(ContextMenu menu, View v, private void loadFragments() {
ContextMenuInfo menuInfo) { FragmentTransaction transaction = this.getFragmentManager().beginTransaction();
super.onCreateContextMenu(menu, v, menuInfo); for(Fragment fragment : this.mFragments){
menu.add(0, DELETE_ID, 0, R.string.delete).setIcon( transaction.add(R.id.fragment_list_contianer, fragment, fragment.getTag());
android.R.drawable.ic_menu_delete); }
transaction.commit();
} }
public boolean onContextItemSelected(MenuItem item) { /**
switch (item.getItemId()) { * Simple Holder class
case DELETE_ID: * @author ricky barrette
Toast.makeText(this.getActivity(), "deleted! (note really)", */
Toast.LENGTH_LONG).show(); class Holder{
return true; public String tag;
} public View view;
return super.onContextItemSelected(item);
} }
} }