Android Open Source - EulerSolutions Problem Select Array Adapter






From Project

Back to project page EulerSolutions.

License

The source code is released under:

MIT License

If you think the Android project EulerSolutions 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 com.eulersolutions.controllers;
/*from  w  w w  .  ja  v a2  s  .c om*/
import java.util.List;

import com.eulersolutions.model.ProblemSummary;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ProblemSelectArrayAdapter extends ArrayAdapter<ProblemSummary> {

  private static final String TAG = "EulerSolution-ProblemSelectArrayAdapter";
  
  private int layoutId;
  private int textViewId;
  
  public ProblemSelectArrayAdapter(Context context, int resource, int textViewResourceId, List <ProblemSummary> newItems) {
    super(context, resource, textViewResourceId);
    Log.i(TAG, "Creating Object");
    layoutId = resource;
    textViewId = textViewResourceId;
    this.addAll(newItems);
  }
  
  @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
    Log.i(TAG, "Building the View");
      LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View toReturn = inflater.inflate(layoutId, parent, false);
      TextView problemName = (TextView) toReturn.findViewById(textViewId);
      problemName.setText(buildString(this.getItem(position)));
      return toReturn;
    }

  @Override
    public long getItemId(int position) {
      return this.getItem(position).getId();
    }

    @Override
    public boolean hasStableIds() {
      return true;
    }
    
    public String buildString(ProblemSummary item)
    {
      Log.i(TAG, "Building the String");
      return "Problem" + item.getId() + ": " + item.getName();
    }
}




Java Source Code List

com.eulersolutions.controllers.MainActivity.java
com.eulersolutions.controllers.ProblemPresentationActivity.java
com.eulersolutions.controllers.ProblemSelectArrayAdapter.java
com.eulersolutions.controllers.ProblemSolutionActivity.java
com.eulersolutions.controllers.SolutionDisplayFragment.java
com.eulersolutions.controllers.SolutionSelectFragment.java
com.eulersolutions.interfaces.ISelectionListener.java
com.eulersolutions.interfaces.ISolutionDisplay.java
com.eulersolutions.interfaces.ISolutionHandler.java
com.eulersolutions.model.CompletedProblems.java
com.eulersolutions.model.EvenFibonacciNmCalculator.java
com.eulersolutions.model.LargestPrimeFactorCalculator.java
com.eulersolutions.model.MultiplesABCalculator.java
com.eulersolutions.model.ProblemCalculator.java
com.eulersolutions.model.ProblemSummary.java