Android Open Source - EulerSolutions Main Activity






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  www . j  ava 2s. co  m*/
import com.eulersolutions.controllers.R;
import com.eulersolutions.model.CompletedProblems;
import com.eulersolutions.model.ProblemSummary;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends Activity {

  private static final String TAG = "EulerSolutions-MainActivity";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "Entered on Create");
    super.onCreate(savedInstanceState);
    CompletedProblems problems = new CompletedProblems(this);
    ProblemSelectArrayAdapter problemAdapter = new ProblemSelectArrayAdapter(this, 
        R.layout.layout_problem_select_row, R.id.problemName, problems.getCompletedProblems());
    
    setContentView(R.layout.activity_main);
    ListView problemListView = (ListView) this.findViewById(R.id.problemSelectListview);
    
    problemListView.setAdapter(problemAdapter);
    problemListView.setOnItemClickListener(new OnItemClickListener(){

      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position,
          long id) {
        Context context;
        Intent displayProblem;
        
        ProblemSelectArrayAdapter adapter = (ProblemSelectArrayAdapter) parent.getAdapter();
        ProblemSummary problem = adapter.getItem(position);
        context = adapter.getContext();
        displayProblem = new Intent(context, ProblemPresentationActivity.class);
        displayProblem.putExtra(ProblemPresentationActivity.PARCEL_NAME, problem);
        context.startActivity(displayProblem);
      }
      });
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }
}




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