Android Open Source - ShareManager Shares Adapter

From Project

Back to project page ShareManager.


The source code is released under:

Copyright (c) 2013, Nelspike All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Red...

If you think the Android project ShareManager 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 share.manager.adapters;
//from ww  w .  j  a v a  2  s.  co  m
import share.manager.stock.R;
import share.manager.utils.FileHandler;
import share.manager.utils.SharesGraphicsBuilder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

public class SharesAdapter extends ArrayAdapter<String> {

  private String[] strings, regions, shares, ticks;
  private Context context;
  private SharesGraphicsBuilder graph;

  public SharesAdapter(Context context, int textViewResourceId,
      String[] objects, String[] regions, String[] shares, String[] ticks,
      SharesGraphicsBuilder graph) {
    super(context, textViewResourceId, objects);
    this.context = context;
    this.strings = objects;
    this.regions = regions;
    this.ticks = ticks;
    this.shares = shares;
    this.graph = graph;

  public View getDropDownView(int position, View convertView, ViewGroup parent) {
    return getCustomView(position, convertView, parent);

  public View getView(int position, View convertView, ViewGroup parent) {
    return getCustomView(position, convertView, parent);

  public View getCustomView(int position, View convertView, ViewGroup parent) {
    final int inner = position;
    LayoutInflater inflater = (LayoutInflater) context
    View row = inflater.inflate(R.layout.shares_box, parent, false);

    TextView label = (TextView) row.findViewById(;

    TextView labelRegion = (TextView) row.findViewById(;

    final TextView labelChange = (TextView) row

    Button minus = (Button) row.findViewById(;
    minus.setOnClickListener(new OnClickListener() {

      public void onClick(View v) {
        if (labelChange.getText().toString().equals("0")) return;

        FileHandler.changeShare(ticks[inner], false);


    Button plus = (Button) row.findViewById(;
    plus.setOnClickListener(new OnClickListener() {

      public void onClick(View v) {
        FileHandler.changeShare(ticks[inner], true);


    return row;

Java Source Code List