84 lines
2.2 KiB
Java
84 lines
2.2 KiB
Java
package org.yaaic.client;
|
|
|
|
import android.view.Gravity;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.AbsListView;
|
|
import android.widget.BaseExpandableListAdapter;
|
|
import android.widget.TextView;
|
|
|
|
/**
|
|
* ServerWindowListAdapater
|
|
*
|
|
* @author Sebastian Kaspari <s.kaspari@googlemail.com>
|
|
*/
|
|
public class ServerWindowListAdapter extends BaseExpandableListAdapter
|
|
{
|
|
private ServerWindow serverWindow;
|
|
private String[] groups = { "Channels (0)", "Queries (0)" };
|
|
|
|
public ServerWindowListAdapter(ServerWindow serverWindow)
|
|
{
|
|
this.serverWindow = serverWindow;
|
|
}
|
|
|
|
public Object getChild(int groupPosition, int childPosition) {
|
|
return "Child";
|
|
}
|
|
|
|
public long getChildId(int groupPosition, int childPosition) {
|
|
return childPosition;
|
|
}
|
|
|
|
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
|
TextView textView = getGenericView();
|
|
textView.setText(getChild(groupPosition, childPosition).toString());
|
|
return textView;
|
|
}
|
|
|
|
public int getChildrenCount(int groupPosition) {
|
|
return 0;
|
|
}
|
|
|
|
public Object getGroup(int groupPosition) {
|
|
return groups[groupPosition];
|
|
}
|
|
|
|
public int getGroupCount() {
|
|
return groups.length;
|
|
}
|
|
|
|
public long getGroupId(int groupPosition) {
|
|
return groupPosition;
|
|
}
|
|
|
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
|
TextView textView = getGenericView();
|
|
textView.setText(getGroup(groupPosition).toString());
|
|
return textView;
|
|
}
|
|
|
|
public boolean hasStableIds() {
|
|
return true;
|
|
}
|
|
|
|
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
|
return true;
|
|
}
|
|
|
|
public TextView getGenericView() {
|
|
// Layout parameters for the ExpandableListView
|
|
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
|
|
ViewGroup.LayoutParams.FILL_PARENT, 64);
|
|
|
|
TextView textView = new TextView(serverWindow);
|
|
textView.setLayoutParams(lp);
|
|
// Center the text vertically
|
|
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
|
|
// Set the text starting position
|
|
textView.setPadding(36, 0, 0, 0);
|
|
return textView;
|
|
}
|
|
|
|
}
|