I'm doing the application fetches the data from the database and displayed in Listview
and Must be all the Classes be a Fragment so I can put it in tabs
The error is:
this.getlistdata.setAdapter(new GetAllSongs(jsonArray,this));
Exactly ... (jsonArray,this)
Full code.
public class GetListData extends Fragment
{
ListView getlistdata;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.getActivity().setContentView(R.layout.activity_main2);
this.getlistdata = (ListView)this.getActivity().findViewById(R.id.listgetdata);
new GetAllCustomerTask().execute(new ApiConnector());
}
public void setListAdapter (JSONArray jsonArray)
{
this.getlistdata.setAdapter(new GetAllSongs(jsonArray,this));
}
private class GetAllCustomerTask extends AsyncTask<ApiConnector,Long,JSONArray>
{
@Override
protected JSONArray doInBackground(ApiConnector... params)
{
return params[0].GetAllCustomers();
}
@Override
protected void onPostExecute(JSONArray jsonArray)
{
setListAdapter(jsonArray);
}
}
The error is ::
can't cast Fragment To Activity
How can I fix it?