Need expert opinion how should i structure this issue. I have a custom method process_filter that resides in a fragment as it needs to access a private TextView
and List
of this fragment.
In the middle of processing, this fragment will access a BaseAdapter
and inside this BaseAdapter
I need to use back process_filter method
Basically here is the structure:
MyFragment.java
public class MyFragment extends Fragment {
private List<String> filter_list;
private TextView no_of_filter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.my_fragment_layout, container, false);
no_of_filter = (TextView) view.findViewById(R.id.no_of_filter_tv);
.
MyAdapter custom_adapter = new MyAdapter(context, "string 1", "string 2");
.
process_filter("string 1", "string 2");
.
}
public void process_filter(String in_preference, String current_value)
{
no_of_filter.setText(in_preference);
}
MyAdapter.java
class MyAdapter extends BaseAdapter {
public View getView( final int position, View convertView, ViewGroup parent)
{
holder.checkBox.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
//Here I need to access back process_filter from fragment
process_filter ("string 1, string 2");
}
}
}
}
See Question&Answers more detail:os