Trying to call a function in a Fragment from a different class - java

I need to call a function in my portfolioActivity Fragment which comes from the class portfolioListAdapter.
It says my parameters are incorrect.
This function works just fine when I'm not using a Fragment, but as I am linking my Fragment to a navigation drawer, it is necessary to keep it this way.
Here is my Fragment:
public class portfolioActivity extends Fragment {
ListView portfolioList;
String[] stockTicker={"AAPL", "GOOG", "MSFT"};
double[] stockPrice={138.96, 830.63, 64.01};
int[] shares={5, 2, 10};
double[] percentChange={0.59, 0.55, 1.43};
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.portfolio_layout, container, false);
portfolioList = (ListView) getView().findViewById(R.id.portfolioListView);
//ADAPTER
ListAdapter adapter = new portfolioListAdapter(this, stockTicker, stockPrice, shares, percentChange);
portfolioList.setAdapter(adapter);
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getActivity().setTitle("Portfolio");
}
}
The error comes when I try to call portfolioListAdapter().
It says there is a problem with the "this" parameter.
Here is my other class:
public class portfolioListAdapter extends ArrayAdapter<String> {
//DECLARATIONS
String[] stockTicker={};
double[] stockPrice={};
int[] shares={};
double[] percentChange={};
Context c;
LayoutInflater inflater;
public portfolioListAdapter(Context context, String[] stockTicker,
double[] stockPrice, int[] shares, double[] percentChange) {
super(context, R.layout.portfolio_row_model, stockTicker);
this.c=context;
this.stockTicker=stockTicker;
this.stockPrice=stockPrice;
this.shares=shares;
this.percentChange=percentChange;
}
public class ViewHolder
{
TextView stockTicker;
TextView stockPrice;
TextView shares;
TextView totalValue;
TextView percentChange;
}
#NonNull
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null)
{
inflater=(LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=inflater.inflate(R.layout.portfolio_row_model, null);
}
// OUR VIEWHOLDER OBJECT
final ViewHolder holder = new ViewHolder();
//INITIALIZE VIEWS
holder.stockTicker= (TextView) convertView.findViewById(R.id.list_portfolio_ticker);
holder.stockPrice= (TextView) convertView.findViewById(R.id.list_portfolio_price);
holder.shares= (TextView) convertView.findViewById(R.id.list_portfolio_shares);
holder.totalValue= (TextView) convertView.findViewById(R.id.list_portfolio_value);
holder.percentChange= (TextView) convertView.findViewById(R.id.list_portfolio_change);
//ASSIGN VIEWS
holder.stockTicker.setText(stockTicker[position]);
holder.stockPrice.setText(String.valueOf("$"+stockPrice[position]));
holder.shares.setText(String.valueOf(shares[position]));
holder.totalValue.setText(String.valueOf("$"+(stockPrice[position]*shares[position])));
holder.percentChange.setText(String.valueOf(percentChange[position]+"%"));
//return super.getView(position, convertView, parent);
return convertView;
}
}

You can't put code after return.
And your parameters are wrong. this is a Fragment, not a Context, you need to use getActivity() or (preferably) onAttach there.
private ListView portfolioList;
private PortfolioListAdapter adapter;
#Override
public void onAttach(Context context) {
super.onAttach(activity);
( (Activity) context).setTitle("Portfolio");
adapter = new PortfolioListAdapter(context, stockTicker, stockPrice, shares, percentChange);
portfolioList.setAdapter(adapter);
}
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.portfolio_layout, container, false);
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
portfolioList = (ListView) view.findViewById(R.id.portfolioListView);
}
Note: You also are not using the ViewHolder correctly.
Might want to read back over how to do that (or use a RecyclerView)

1) Can't put code after return.
2) Constructor for adapter is expecting a "Context" object. What you are passing is a fragment object(this)
Add this code fragment
private Context mContext;
#Override
public void onAttach(Context context) {
super.onAttach(context);
mContext = context;
}
And in call to adapter pass mContext instead of this.

Related

starting a class in a fragment

So I haven't seen any question like this and I have a problem I don't know how to start the other class from the fragment. I have been trying all day and I still can't find the answer. First of all how do I start my imageadapter class and how the hell can I write additional methods into the class and then execute them in the fragment class?
public class ImageFragment extends Fragment {
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_image, container, false);
GridView gridView = (GridView)getView().findViewById(R.id.gridView);
gridView.setAdapter(new imageadapter(getContext()));
}
}
but why does this then not work ?
public class ImageFragment extends Fragment {
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_image, container, false);
}
#Override
public void onViewCreated(#NonNull final View view, #Nullable Bundle savedInstanceState) {}
GridView gridView = (GridView)getView().findViewById(R.id.gridView);
gridView.setAdapter(new imageadapter(this));
}
I still get errors by the words this and the setAdapter.
All you need to do is add an onViewCreated method where you can do call your methods and other stuff. Here's my code.
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_upcoming, container, false);
}
#Override
public void onViewCreated(#NonNull final View view, #Nullable Bundle savedInstanceState) {
//you can call your methods and find your views in here
setHasOptionsMenu(true);
final FloatingActionButton fab = view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), CreateEditAppointmentActivity.class);
startActivityForResult(intent, RC_ADD_CLIENT);
}
});
coordinatorLayout = view.findViewById(R.id.upcomingLayout);
}

problem with removing previous view in a fragment

i have created a fragment in android that contain 2 functions, the startview() is called at the beginning when the fragment is called, then when user click a button childfragment() is called. and at that point it should have remove the view from the startview() and then replacing it with the newview from childfragment(), and thats what i thought it would do. But instead it did not remove the old view and place the newview on top of the old view. even thought i already place mContainer.removeAllViews(); it did not remove the old view. what am i missing? please help.
here is the code
#SuppressLint("ValidFragment")
public class FragmentSideContent extends android.app.Fragment {
//private OnFragmentInteractionListener mListener;
Context context;
View view,trueview;
ListView listView;
ListAdapter listAdapter;
private LayoutInflater mInflater;
private ViewGroup mContainer;
int[] image = {1,2,3};
String[] titleText = {"one","two","three","one","two","three","one","two","three","one","two","three"};
String[] subTitleText = {"one","two","three","one","two","three","one","two","three","one","two","three"};
public FragmentSideContent(Context context) {
this.context = context;
}
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container,#Nullable Bundle savedInstanceState) {
mInflater = inflater;
mContainer = container;
startview();
return trueview;
}
public void startview(){
view = mInflater.inflate(R.layout.fragment_sidecontent,mContainer,false);
listView = (ListView) view.findViewById(R.id.noteList);
listAdapter = new ListAdapter(context,image,titleText,subTitleText);
listView.setAdapter(listAdapter);
trueview = view;
}
public void childfragment(){
mContainer.removeAllViews();
View newview = mInflater.inflate(R.layout.fragment_sidecontent,mContainer,false);
Fragment childFragment = new FragmentList(context);
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.child_fragment_container, childFragment).commit();
mContainer.addView(newview);
mContainer.addView(trueview);
trueview = newview;
}
}
I recommend you put in your fragment layout some GroupView for do this.
fragment_layout.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
in yout Fragment.java
View view;
Framelayout fContainer;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_layout, container, false);
return startView();
}
public View startview(){
fContainer = (Framelayout) view.findViewById(R.id.container);
listView = (ListView) view.findViewById(R.id.noteList);
listAdapter = new ListAdapter(context,image,titleText,subTitleText);
listView.setAdapter(listAdapter);
return view;
}
public void childfragment(){
fContainer.removeAllViews();
Fragment childFragment = new FragmentList(context);
FragmentTransaction transaction =
getChildFragmentManager().beginTransaction();
transaction.replace(R.id.container, childFragment).commit();
}
Now in your oncreateview of the other fragment (FragmentList) put the view that you want inflate.
FragmentList.java
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View newview = mInflater.inflate(R.layout.fragment_sidecontent,mContainer,false);
return newview;
}

How to pass data from Recyclerview to Fragment

I have a recyclerView populated in a Fragment and I want to Launch a new Fragment and pass data from the adapter ,I try to use Bundles but it always give a null value this my Adapter Class
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.MyViewHolder> {
private LayoutInflater inflater;
private List<Information> mList;
private FragmentCommunication mCommunicator;
public RecyclerAdapter(Context context, List<Information> list,FragmentCommunication communication) {
inflater = LayoutInflater.from(context);
mList = list;
mCommunicator=communication;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.single_row, parent, false);
MyViewHolder holder = new MyViewHolder(view,mCommunicator);
return holder;
}
#Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
final Information current = mList.get(position);
holder.name.setText(current.name);
holder.job.setText(current.job);
FragmentB fragmentB=new FragmentB();
Bundle bundle=new Bundle();
bundle.putString("NAME",current.name);
bundle.putString("JOB",current.job);
fragmentB.setArguments(bundle);
}
#Override
public int getItemCount() {
return mList.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView name;
TextView job;
FragmentCommunication mComminication;
public MyViewHolder(View itemView, FragmentCommunication Communicator) {
super(itemView);
name = (TextView) itemView.findViewById(R.id.tv_name);
job = (TextView) itemView.findViewById(R.id.tv_gob);
mComminication=Communicator;
name.setOnClickListener(this);
}
#Override
public void onClick(View view) {
mComminication.respond(getAdapterPosition());
}
}
and this is my new Fragment that I want to launch
public class FragmentB extends Fragment {
TextView textview;
TextView textView2;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.fragment_b,container,false);
textview= (TextView) view.findViewById(R.id.tv_name);
textView2= (TextView) view.findViewById(R.id.tv_job);
return view;
}
#Override
public void onActivityCreated(#Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle arguments = getArguments();
if (arguments!=null){
String name= arguments.get("NAME").toString();
String job= arguments.get("JOB").toString();
textview.setText(name);
textView2.setText(job);}
}
}
this is how I connect Fragment and recyclerview Adapter
with interface
public interface FragmentCommunication {
void respond(int position);
}
and this the Fragment where the recyclerview is populated
public class RecyclerViewFragment extends Fragment {
RecyclerView mRecyclerView;
RecyclerAdapter mRecyclerAdapter;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.recycler_fragment,container,false);
mRecyclerView= (RecyclerView) view.findViewById(R.id.recycler);
mRecyclerAdapter=new RecyclerAdapter(getActivity(),getData(),communication);
mRecyclerView.setAdapter(mRecyclerAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return view;
}
public static List<Information> getData() {
List<Information>data=new ArrayList<>();
String[] names={"ahmed","mohammed"};
String[] jobs={"sacsd","csscs"};
for (int i=0;i<names.length;i++){
Information current=new Information();
current.name=(names[i]);
current.job=(jobs[i]);
data.add(current);
}
return data;
}
FragmentCommunication communication=new FragmentCommunication() {
#Override
public void respond(int position) {
FragmentB fragmentB=new FragmentB();
FragmentManager manager=getFragmentManager();
FragmentTransaction transaction=manager.beginTransaction();
transaction.replace(R.id.dumper,fragmentB).commit();
}
};
}
and my mainActivity class is just add the RecyclerViewFragment
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerViewFragment fragment=new RecyclerViewFragment();
FragmentManager manager=getSupportFragmentManager();
FragmentTransaction transaction=manager.beginTransaction();
transaction.add(R.id.dumper,fragment).commit();
}
}
so what is the right way to launch fragmentB and pass the data from recyclerview Adapter to fragmentB
thank you guys for the answer,I solved the problem using an interface with String values to connect the adapter with the fragment that contains the recyclerview and the other fragment here is what I did exactly :
this is the interface
public interface FragmentCommunication {
void respond(int position,String name,String job);
}
and this is the adapter
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.MyViewHolder> {
private LayoutInflater inflater;
private List<Information> mList;
private FragmentCommunication mCommunicator;
public RecyclerAdapter(Context context, List<Information> list,FragmentCommunication communication) {
inflater = LayoutInflater.from(context);
mList = list;
mCommunicator=communication;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.single_row, parent, false);
MyViewHolder holder = new MyViewHolder(view,mCommunicator);
return holder;
}
#Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
final Information current = mList.get(position);
holder.name.setText(current.name);
holder.job.setText(current.job);
FragmentB fragmentB=new FragmentB();
Bundle bundle=new Bundle();
bundle.putString("NAME",current.name);
bundle.putString("JOB",current.job);
fragmentB.setArguments(bundle);
}
#Override
public int getItemCount() {
return mList.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView name;
TextView job;
FragmentCommunication mComminication;
public MyViewHolder(View itemView, FragmentCommunication Communicator) {
super(itemView);
name = (TextView) itemView.findViewById(R.id.tv_name);
job = (TextView) itemView.findViewById(R.id.tv_gob);
mComminication=Communicator;
name.setOnClickListener(this);
}
#Override
public void onClick(View view) {
mComminication.respond(getAdapterPosition(),mList.get(getAdapterPosition()).name,mList.get(getAdapterPosition()).job);
}
}
}
the fragment that contains the recyclerview
public class RecyclerViewFragment extends Fragment {
RecyclerView mRecyclerView;
RecyclerAdapter mRecyclerAdapter;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.recycler_fragment,container,false);
mRecyclerView= (RecyclerView) view.findViewById(R.id.recycler);
mRecyclerAdapter=new RecyclerAdapter(getActivity(),getData(),communication);
mRecyclerView.setAdapter(mRecyclerAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return view;
}
public static List<Information> getData() {
List<Information>data=new ArrayList<>();
String[] names={"ahmed","mohammed"};
String[] jobs={"sacsd","csscs"};
for (int i=0;i<names.length;i++){
Information current=new Information();
current.name=(names[i]);
current.job=(jobs[i]);
data.add(current);
}
return data;
}
FragmentCommunication communication=new FragmentCommunication() {
#Override
public void respond(int position,String name,String job) {
FragmentB fragmentB=new FragmentB();
Bundle bundle=new Bundle();
bundle.putString("NAME",name);
bundle.putString("JOB",job);
fragmentB.setArguments(bundle);
FragmentManager manager=getFragmentManager();
FragmentTransaction transaction=manager.beginTransaction();
transaction.replace(R.id.dumper,fragmentB).commit();
}
};
}
this is the fragmentB where I get the Strings from the Adapter
public class FragmentB extends Fragment {
TextView textview;
TextView textview2;
String name;
String job;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
name=getArguments().getString("NAME");
job=getArguments().getString("JOB");
}
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.fragment_b,container,false);
textview= (TextView) view.findViewById(R.id.getName);
textview2= (TextView) view.findViewById(R.id.getJob);
textview.setText(name);
textview2.setText(job);
return view;
}
}
If you are working with kotlin, the solution is much simpler.
Original Answer here
pass the function val itemClick: (Int) -> Unit to your adapter.
class MyRecyclerViewAdapter(params , val itemClick: (Int) -> Unit): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
internal inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
...
itemView.setOnClickListener( {itemClick(layoutPosition)} )
}
}
In your fragment use the returned value position
val myAdapter = MyRecyclerViewAdapter(params) { position ->
// do something
}
Either creating a listener interface in the adapter or using regular old getters, if I understand your question correctly.
You need to pass the Bundle to the fragment through the setArguments(Bundle args) method. Since you have not set arguments, the bundle you try to extract in your Fragment resolves to null.
You have the right idea with using a Bundle. You just need to pass it to the Fragment by calling setArguments(). Then you retrieve the Bundle in your Fragment with getArguments().
Note that instead of mList.get(position).name, you can do current.name. Similarly for job.
Another part of the problem is that you create FragmentB on two different places. In one place you also call setArguments() but do not show the fragment. In the other you show the fragment but do not call setArguments(). If you really need to do this from multiple parts of your code you should write a method to avoid these inconsistencies.

Pass object from GridView of Fragment to ListView of another Fragment

I have a GridView in FragmentA containing all objects. When the user tap on each object, these objects are added into ListView of FragmentB.
Note that FragmentA and FragmentB are both in the same Activity, side by side.
I have tried using Bundle to send object from FragmentA to FragmentB but I was stucked as I have no idea how FragmentB is going to know that a new object has been added.
Bundle object is sent from ProductGridAdapter (under FragmentA) and receiver will be FragmentB where FragmentB will update the ListView for the latest objects added by FragmentA
Here is my code:
ProductGridAdapter.java
public class ProductGridAdapter extends ArrayAdapter<Product> {
private List<Product> productList;
private Context context;
public ProductGridAdapter(Context context, int resource,
List<Product> objects) {
super(context, resource, objects);
this.context = context;
this.productList = objects;
}
#Override
public int getCount() {
return ((null != productList) ?
productList.size() : 0);
}
#Override
public Product getItem(int position) {
return ((null != productList) ?
productList.get(position) : null);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(null == view) {
view = layoutInflater.inflate(R.layout.grid_product, null);
}
final Product product = productList.get(position);
if(product != null) {
final CardView productGridLayout = (CardView) view.findViewById(R.id.product_gridlayout);
final TextView productName = (TextView) view.findViewById(R.id.product_name);
final ImageView productIcon = (ImageView) view.findViewById(R.id.product_icon);
productName.setText(product.getName());
productIcon.setImageDrawable(product.getDrawable());
productGridLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
FragmentB fragment = new FragmentB();
Bundle bundle = new Bundle();
bundle.putSerializable("product", product);
fragment.setArguments(bundle);
}
});
}
return view;
}
}
FragmentA.java
public class FragmentA extends Fragment {
private GridView gridView;
private ProductGridAdapter productAdapter;
public FragmentA() {
// Required empty public constructor
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_product_display, container, false);
gridView = (GridView) rootView.findViewById(R.id.gridview);
productAdapter = new ProductGridAdapter(getActivity(), R.layout.fragment_product_display, getProductList());
gridView.setAdapter(productAdapter);
gridView.destroyDrawingCache();
gridView.setVisibility(GridView.INVISIBLE);
gridView.setVisibility(GridView.VISIBLE);
return rootView;
}
}
FragmentB.java
public class FragmentB extends Fragment {
private ListView listView;
private PaymentListAdapter paymentAdapter;
private LinearLayout button;
private ArrayList<String> arr;
public FragmentB() {
// Required empty public constructor
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_payment, container, false);
listView = (ListView) rootView.findViewById(android.R.id.list);
paymentAdapter = new PaymentListAdapter(getActivity(), R.layout.fragment_payment, getProductList());
// button = (LinearLayout) rootView.findViewById(R.id.payment);
listView.setAdapter(paymentAdapter);
Bundle bundle = this.getArguments();
Product product = (Product) bundle.getSerializable("product");
return rootView;
}
you can have two common method in interface class in main activity, To update view in both fragment,When some changes happens in FragmentA you have to notify that changes to main activity then main activity should communicate to FragementB about that changes.try to do as like this,Hope this will help you.Happy Coding!

onListItemClick in Fragment

I need use onListItemClick in my class, it's an extends Fragment, I don't how can I use it in my class, somebody knows how can I call it?
public class VisitaFragment extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_visita, container, false);
return rootView;
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Visitas visita = new Visitas();
List<Visita> visitas = visita.getVisitas();
final ListVisitaAdapter visitaAdapter = new ListVisitaAdapter(getActivity(), visitas);
ListView listVisitas = (ListView) getActivity().findViewById(R.id.lv_visita_emvisita);
listVisitas.setAdapter(visitaAdapter);
//-->> onListItemClick
}
}
listVisitas.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
Extend android.app.ListFragment instead of Fragment. It contains an onListItemClick() method that you can override.

Categories

Resources