Muchas gracias!
Activity_Main.xml
Código PHP:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ExpandableListView
android:id="@+id/expandableListView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
</ExpandableListView>
</RelativeLayout>
AdpLv.java
Código PHP:
package com.akiba.ioweu;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
public class AdpLv extends BaseExpandableListAdapter {
private Context context;
String[]parentList={"Diego","Pablo","Juan","Pito","Pete"};
String[][]childList={
{
"Diego1"
},
{
"Pablo1"
},
{
"Juan1"
},
{
"Pito1"
},
{
"Pete1"
},
};
public AdpLv(Context context) {
// TODO Auto-generated constructor stub
this.context=context;
}
public Object getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return null;
}
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return 0;
}
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TextView tv = new TextView(context);
tv.setText(childList[groupPosition][childPosition]);
return tv;
}
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
return childList[groupPosition].length;
}
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
public int getGroupCount() {
// TODO Auto-generated method stub
return parentList.length;
}
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TextView tv = new TextView(context);
tv.setText(parentList[groupPosition]);
return tv;
}
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return true;
}
}
Código PHP:
package com.akiba.ioweu;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.widget.ExpandableListView;
public class MainActivity extends Activity {
private ExpandableListView lv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SQLiteDatabase db = openOrCreateDatabase("iOweU",MODE_PRIVATE,null);
try {
/*esto hay que sacarlo, lo pongo solamente para ir editando las tablas*/
db.execSQL("DROP TABLE IF EXISTS People;");
db.execSQL("DROP TABLE IF EXISTS Loans;");
db.execSQL("CREATE TABLE IF NOT EXISTS People (PeopleID int(5)," +
" LastName varchar, " +
" FirstName varchar, " +
" Mail varchar);");
db.execSQL("CREATE TABLE IF NOT EXISTS Loans (PeopleID int(5)," +
" AmountIN decimal(6,5)," +
" AmountOUT decimal(6,5)," +
" Interest decimal(6,5));");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Error al crear las tablas");
alertDialog.setMessage("Huvo un error al momento de crear las tablas.");
alertDialog.show();
}
lv = (ExpandableListView)findViewById(R.id.expandableListView1);
lv.setAdapter(new AdpLv(this));
db.close();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}