Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.andrei.iou;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import android.R.string;
- import android.os.Bundle;
- import android.app.Activity;
- import android.app.ExpandableListActivity;
- import android.view.Menu;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ExpandableListAdapter;
- import android.widget.ListView;
- import android.widget.SimpleExpandableListAdapter;
- public class IOweYou extends Activity{
- private static final String NAME = "NAME";
- private static final String DESC = "DESCRIPTION";
- EditText nameField, availableAmount, billName, billAmount, OwesMoney, waitingMoney, owesAmount;
- Button addAmount, addBill, addOwe, calculate, clear;
- List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
- List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
- ListView listview;
- ExpandableListAdapter mAdapter;
- ExpandableListActivity localEL = new ExpandableListActivity();
- String tempName, tempAmount, tempOther;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_iowe_you);
- nameField = (EditText)findViewById(R.id.nameField);
- availableAmount = (EditText)findViewById(R.id.editText1);
- billName = (EditText)findViewById(R.id.editText2);
- billAmount = (EditText)findViewById(R.id.editText3);
- OwesMoney = (EditText)findViewById(R.id.editText4);
- waitingMoney = (EditText)findViewById(R.id.editText6);
- owesAmount = (EditText)findViewById(R.id.editText5);
- addAmount = (Button)findViewById(R.id.button1);
- addBill = (Button)findViewById(R.id.button2);
- addOwe = (Button)findViewById(R.id.button3);
- calculate = (Button)findViewById(R.id.button4);
- clear = (Button)findViewById(R.id.button5);
- Map<String, String> curGroupMap = new HashMap<String, String>();
- groupData.add(curGroupMap);
- curGroupMap.put(NAME, "People");
- curGroupMap.put(DESC, "All names of people entered so far");
- List<Map<String, String>> Peoplechildren = new ArrayList<Map<String, String>>();
- curGroupMap.put(NAME, "Bills");
- curGroupMap.put(DESC, "Any pending bills you need to pay");
- List<Map<String, String>> Billschildren = new ArrayList<Map<String, String>>();
- curGroupMap.put(NAME, "IOU");
- curGroupMap.put(DESC, "People owing people money");
- List<Map<String, String>> IOUchildren = new ArrayList<Map<String, String>>();
- // Set up our adapter
- mAdapter = new SimpleExpandableListAdapter(
- this,
- groupData,
- android.R.layout.simple_expandable_list_item_1,
- new String[] { NAME, DESC },
- new int[] { android.R.id.text1, android.R.id.text2 },
- childData,
- android.R.layout.simple_expandable_list_item_2,
- new String[] { NAME, DESC },
- new int[] { android.R.id.text1, android.R.id.text2 }
- );
- localEL.setListAdapter(mAdapter);
- addAmount.setOnClickListener(new OnClickListener(){
- public void onClick(View v){
- tempName = nameField.getText().toString();
- tempAmount = availableAmount.getText().toString();
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.activity_iowe_you, menu);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement