Created
June 23, 2016 12:41
-
-
Save ramuta/67088eba4befa417918765581e2659de to your computer and use it in GitHub Desktop.
HappyInvestor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.nino.financeappv20; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.TextView; | |
import com.example.nino.financeappv20.model.FinanceData; | |
/** | |
* Created by Nino on 16. 06. 2016. | |
*/ | |
public class StockAdapter extends BaseAdapter{ | |
public static final FinanceData[] DATA = new FinanceData[] { | |
new FinanceData("GOOG", 139.41f), | |
new FinanceData("MS", 139.41f), | |
new FinanceData("FB", 139.41f), | |
}; | |
private final LayoutInflater layoutInflater; | |
private FinanceData[] data; | |
public StockAdapter(Context context, FinanceData[] data) { | |
this.layoutInflater = LayoutInflater.from(context); | |
this.data = data; | |
} | |
@Override | |
public int getCount() { | |
if (data != null) { | |
return data.length; | |
} else { | |
return 0; | |
} | |
} | |
@Override | |
public FinanceData getItem(int position) { | |
return data[position]; | |
} | |
@Override | |
public long getItemId(int position) { | |
return position; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
View view = convertView; | |
if (view == null) { | |
view = layoutInflater.inflate(android.R.layout.simple_list_item_1, parent, false); | |
} | |
FinanceData item = getItem(position); | |
TextView title = (TextView) view.findViewById(android.R.id.text1); | |
title.setText(item.getSymbol()); | |
return view; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment