Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: Java  |  size: 3.72 KB  |  views: 50  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.andrei.iou;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7.  
  8. import android.R.string;
  9. import android.os.Bundle;
  10. import android.app.Activity;
  11. import android.app.ExpandableListActivity;
  12. import android.view.Menu;
  13. import android.view.View;
  14. import android.view.View.OnClickListener;
  15. import android.widget.Button;
  16. import android.widget.EditText;
  17. import android.widget.ExpandableListAdapter;
  18. import android.widget.ListView;
  19. import android.widget.SimpleExpandableListAdapter;
  20.  
  21. public class IOweYou extends Activity{
  22.        
  23.         private static final String NAME = "NAME";
  24.         private static final String DESC = "DESCRIPTION";
  25.         EditText nameField, availableAmount, billName, billAmount, OwesMoney, waitingMoney, owesAmount;
  26.         Button addAmount, addBill, addOwe, calculate, clear;
  27.         List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
  28.         List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
  29.         ListView listview;
  30.         ExpandableListAdapter mAdapter;
  31.         ExpandableListActivity localEL = new ExpandableListActivity();
  32.        
  33.         String tempName, tempAmount, tempOther;
  34.        
  35.        
  36.     @Override
  37.     public void onCreate(Bundle savedInstanceState) {
  38.         super.onCreate(savedInstanceState);
  39.         setContentView(R.layout.activity_iowe_you);
  40.        
  41.         nameField = (EditText)findViewById(R.id.nameField);
  42.         availableAmount = (EditText)findViewById(R.id.editText1);
  43.         billName = (EditText)findViewById(R.id.editText2);
  44.         billAmount = (EditText)findViewById(R.id.editText3);
  45.         OwesMoney = (EditText)findViewById(R.id.editText4);
  46.         waitingMoney = (EditText)findViewById(R.id.editText6);
  47.         owesAmount = (EditText)findViewById(R.id.editText5);
  48.        
  49.         addAmount = (Button)findViewById(R.id.button1);
  50.         addBill = (Button)findViewById(R.id.button2);
  51.         addOwe = (Button)findViewById(R.id.button3);
  52.         calculate = (Button)findViewById(R.id.button4);
  53.         clear = (Button)findViewById(R.id.button5);
  54.        
  55.        
  56.         Map<String, String> curGroupMap = new HashMap<String, String>();
  57.                 groupData.add(curGroupMap);
  58.                 curGroupMap.put(NAME, "People");
  59.                 curGroupMap.put(DESC, "All names of people entered so far");
  60.                 List<Map<String, String>> Peoplechildren = new ArrayList<Map<String, String>>();
  61.                 curGroupMap.put(NAME, "Bills");
  62.                 curGroupMap.put(DESC, "Any pending bills you need to pay");
  63.                 List<Map<String, String>> Billschildren = new ArrayList<Map<String, String>>();
  64.                 curGroupMap.put(NAME, "IOU");
  65.                 curGroupMap.put(DESC, "People owing people money");
  66.                 List<Map<String, String>> IOUchildren = new ArrayList<Map<String, String>>();    
  67.                
  68.                  // Set up our adapter
  69.        mAdapter = new SimpleExpandableListAdapter(
  70.                 this,
  71.                 groupData,
  72.                 android.R.layout.simple_expandable_list_item_1,
  73.                 new String[] { NAME, DESC },
  74.                 new int[] { android.R.id.text1, android.R.id.text2 },
  75.                 childData,
  76.                 android.R.layout.simple_expandable_list_item_2,
  77.                 new String[] { NAME, DESC },
  78.                 new int[] { android.R.id.text1, android.R.id.text2 }
  79.                 );
  80.         localEL.setListAdapter(mAdapter);
  81.        
  82.         addAmount.setOnClickListener(new OnClickListener(){
  83.                 public void onClick(View v){
  84.                         tempName = nameField.getText().toString();
  85.                         tempAmount = availableAmount.getText().toString();
  86.                
  87.                 }
  88.         });
  89.        
  90.        
  91.        
  92.     }
  93.  
  94.     @Override
  95.     public boolean onCreateOptionsMenu(Menu menu) {
  96.         getMenuInflater().inflate(R.menu.activity_iowe_you, menu);
  97.         return true;
  98.     }
  99.    
  100. }