Back to project page Do-not-get-annoyed.
The source code is released under:
Apache License
If you think the Android project Do-not-get-annoyed listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package mn100013d.pmu; //w ww . ja va2s . co m import java.util.ArrayList; import mn100013d.pmu.data.GameDataDbHelper; import mn100013d.pmu.models.Result; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.DisplayMetrics; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.OvershootInterpolator; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; public class ScoresFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_scores, container, false); ListView lResults = (ListView) rootView .findViewById(R.id.listView_results); GameDataDbHelper dbHandler = new GameDataDbHelper(getActivity()); ArrayList<Result> dResults = dbHandler.getAllEntries(); MainAdapter mAdapter = new MainAdapter(getActivity(), dResults); if (mAdapter != null) lResults.setAdapter(mAdapter); return rootView; } public class MainAdapter extends ArrayAdapter<Result> { private Context context; private LayoutInflater mInflater; private ArrayList<Result> results; private class Holder { public TextView textview; } public MainAdapter(Context context, ArrayList<Result> results) { super(context, 0, results); this.context = context; this.mInflater = (LayoutInflater) this.context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.results = results; } @Override public View getView(final int position, View convertView, ViewGroup parent) { final Result result = this.results.get(position); final Holder holder; if (convertView == null) { convertView = mInflater.inflate( android.R.layout.simple_list_item_1, null); convertView.setBackgroundColor(0xFF202020); holder = new Holder(); holder.textview = (TextView) convertView .findViewById(android.R.id.text1); holder.textview.setTextColor(0xFFFFFFFF); convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); } holder.textview.setText(result.toString()); Animation animation = null; animation = AnimationUtils.loadAnimation(getActivity(), R.anim.animation_shake); animation.setDuration(500); convertView.startAnimation(animation); animation = null; return convertView; } } @Override public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) { Animation anim = null; if (enter) anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left); else { anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right); } anim.setInterpolator(new OvershootInterpolator(3f)); return anim; } }