• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps getParent() in android with BaseAdapter

krishnaveni

Well-Known Member
I have to develop an one android application.

Here i have using tabgroup activity.

i have using following code on my adapter file:

HTML:
convertView.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(View v) {
                 ArrayList<SubCategory> beanSubCat = categoriesList.getmSubCategories();
                Intent intent = new Intent(getParent(),SubCategoryDetails.class);
                 TabGroupActivity parentActivity = (TabGroupActivity) getParent();
                intent.putExtra("SubCategoryDetails", beanSubCat);
                intent.putExtra("title", categoriesList.getmCategoryName());
    parentActivity.startChildActivity("SubCategoryDetails",intent);

i am getting the following error :

The method getParent() is undefined for the type new View.OnClickListener(){}

How can i resolve these error .. please give me solution for these ???



I have using adapter class here.(For eg:public class CategoriesAdapter extends BaseAdapter)how can i get the getparent() in Adapter class ??? please give me solution ???



I have using following code:

[HIGH] Intent intent = new Intent(activity,SubCategoryDetails.class);
intent.putExtra("SubCategoryDetails", beanSubCat);
intent.putExtra("title", categoriesList.getmCategoryName());
activity.startActivity(intent);[/HIGH]
Now am activity is going to next activity well.

But i have using tabgroupactivity means am getting above error ??? please give me any ideas ???
 
I have declared globally private Activity activity;

after that i have change my code like:

Intent intent = new Intent(activity.getParent(),SubCategoryDetails.class); TabGroupActivity parentActivity = (TabGroupActivity) activity.getParent();

Now i got the solution.
 
Back
Top Bottom