Saturday, May 12, 2012

[android-developers] in Exapndible list view on clicklistener

i am doing expandible listview ,its working fine ,when iam trying set
for onlcik listener for childlist in for textview .setonclicklistner
with another activity its not working ..
see my code..
public class CompaniesActivity extends ExpandableListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setListAdapter(new ExampleAdapter(this));
}
private class ExampleAdapter extends BaseExpandableListAdapter
implements OnClickListener {
private Context context;
public ExampleAdapter(Context context) {
this.context = context;
}
public Object getChild(int groupPosition, int childPosition) {
return null;
}
public long getChildId(int groupPosition, int childPosition) {
return 0;
}
/**
* getChildView overridden method will have responsibility of
* constructing View for the child element when corresponding
* group element is activated by click / touch action.
*/

public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
LinearLayout linear = new LinearLayout(this.context);
LinearLayout linear1 = new LinearLayout(this.context);

TextView tv = null,
tv1=null;
//Button b1= null;


if(groupPosition == 0) {
tv = new TextView(this.context);
tv1 = new TextView(this.context);

tv.setTextColor(Color.BLUE);
tv.getBackground().setAlpha(0);


tv.setText("Las");
tv.setPadding(70, 0, 0, 0);
tv.setClickable(true);
tv.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
Intent clickIntent = new Intent();
clickIntent.setClass(getApplicationContext(), LinkActivity.class);
startActivity(clickIntent);

}
});
linear1.addView(tv);
//linear1.addView(b1);
linear.addView(linear1);

}
if(groupPosition == 1) {

tv = new TextView(this.context);
tv.setText("North America");

linear.addView(tv);

}
return linear;
}
public int getChildrenCount(int groupPosition) {
return 1;
}
public Object getGroup(int groupPosition) {
return null;
}
public int getGroupCount() {
return 5;
}
public long getGroupId(int groupPosition) {
return 0;
}
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
LinearLayout linear = new LinearLayout(this.context);

if(groupPosition == 0) {
TextView txtView = new TextView(this.context);
txtView.setText(("Philips HealthCare:").toUpperCase());
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);


}
if(groupPosition == 1) {


TextView txtView = new TextView(this.context);
txtView.setText(("Siemens").toUpperCase());
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);

}
if(groupPosition == 2) {


TextView txtView = new TextView(this.context);
txtView.setText(("Samsung Healthcare").toUpperCase());
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);

}
if(groupPosition == 3) {


TextView txtView = new TextView(this.context);
txtView.setText(("Pacific").toUpperCase());
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);

}
if(groupPosition == 4) {


TextView txtView = new TextView(this.context);
txtView.setText(("Atlantic").toUpperCase());
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);

}
if(groupPosition == 5) {


TextView txtView = new TextView(this.context);
txtView.setText("South Regions");
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);

}
if(groupPosition == 6) {


TextView txtView = new TextView(this.context);
txtView.setText(("Atlantic").toUpperCase());
txtView.setTextColor(Color.RED);
txtView.setPadding(70, 0, 0, 0);
linear.addView(txtView);

}
return linear;
}
public boolean hasStableIds() {
return false;
}
public boolean isChildSelectable(int groupPosition,
int childPosition) {
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub

}
}

}


can any one tell me for this ..

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate