Android Open Source - Wordjambalaya Fragment Result






From Project

Back to project page Wordjambalaya.

License

The source code is released under:

GNU General Public License

If you think the Android project Wordjambalaya listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package nz.co.martinpaulo.wordjambalaya;
//  w  w  w.ja  va 2s. c  o  m
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;


public class FragmentResult extends ListFragment {

    public FragmentResult() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        List<List<String>> possibleAnswers = (List<List<String>>) getActivity().
                getIntent().getSerializableExtra(FragmentAnswer.RESULTS_AHOY);
        ResultAdapter ra = new ResultAdapter(possibleAnswers);
        setListAdapter(ra);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        //https://code.google.com/p/android/issues/detail?id=21742
        // http://baroqueworksdev.blogspot.com.au/2012/02/how-to-use-listfragment.html
        //((TextView)getListView().getEmptyView()).setText("No results have been found :(");
        return inflater.inflate(R.layout.fragment_result, container, false);
    }

    private class ResultAdapter extends ArrayAdapter<List<String>> {
        public ResultAdapter(List<List<String>> possibleAnswers) {
            super(getActivity(), 0, possibleAnswers);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_result, null);
            }
            TextView tv = (TextView) convertView.findViewById(R.id.list_item_result_text);
            String answer = "<b>" + position + ":</b> ";

            List<String> possibleAnswer = getItem(position);
            for (String word : possibleAnswer) {
                answer = answer + word + " ";
            }
            tv.setText(Html.fromHtml(answer));
            return convertView;
        }


    }


}




Java Source Code List

nz.co.martinpaulo.wordjambalaya.ActivityJambalaya.java
nz.co.martinpaulo.wordjambalaya.ActivityResult.java
nz.co.martinpaulo.wordjambalaya.ApplicationTest.java
nz.co.martinpaulo.wordjambalaya.DictionaryTest.java
nz.co.martinpaulo.wordjambalaya.Dictionary.java
nz.co.martinpaulo.wordjambalaya.FragmentAnswer.java
nz.co.martinpaulo.wordjambalaya.FragmentResult.java
nz.co.martinpaulo.wordjambalaya.FragmentUnknownWords.java
nz.co.martinpaulo.wordjambalaya.UnknownWord.java
nz.co.martinpaulo.wordjambalaya.UnknownWords.java
nz.co.martinpaulo.wordjambalaya.WordDrawingView.java
nz.co.martinpaulo.wordjambalaya.WordLengthPicker.java