Please, help to figure out why view binding onItemClickListener doesn't work.
To be short: I'm loading list of fragments. And need to choose fragment to load by clicking to item, so I implemented AdapterView.OnItemClickListener for this purpose. But when I perform a click - nothing happens, method does't called.
public class ChooserFragment extends ListFragment implements AdapterView.OnItemClickListener {
private ChooserFragmentBinding mBinding;
private static final Class<?>[] CLASSES = new Class[]{
EmailPasswordFragment.class,
EmailPasswordFragment.class,
};
private static final int[] DESCRIPTION_IDS = new int[]{
R.string.desc_emailpassword,
R.string.desc_emailpassword,
};
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
mBinding = ChooserFragmentBinding.inflate(inflater, container, false);
View view = mBinding.getRoot();
CustomArrayAdapter adapter = new CustomArrayAdapter(getContext(), android.R.layout.simple_list_item_2, CLASSES);
adapter.setDescriptionIds(DESCRIPTION_IDS);
mBinding.list.setAdapter(adapter);
mBinding.list.setOnItemClickListener(this);
return view;
}
#Override
public void onDestroyView() {
super.onDestroyView();
mBinding = null;
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Class<?> clicked = CLASSES[position];
Log.d("Clicked", String.valueOf(position));
}
public static class CustomArrayAdapter extends ArrayAdapter<Class<?>> {
private Context mContext;
private int[] mDescriptionIds;
public CustomArrayAdapter(Context context, int resource, Class[] objects) {
super(context, resource, objects);
mContext = context;
}
#SuppressWarnings("NullableProblems")
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(android.R.layout.simple_list_item_1, null);
}
((TextView) view.findViewById(android.R.id.text1)).setText(mDescriptionIds[position]);
return view;
}
public void setDescriptionIds(int[] descriptionIds) {
mDescriptionIds = descriptionIds;
}
}
}
XML layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
Thanks.
Is there some reason you have to have the Fragment extend ListFragment and implement AdapterView.OnItemClickListener? Try it the normal way and see what happens:
mBinding.list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("LOG", "test");
}
});
Related
When I click the listview in tab Fragment 1 it won't work jump into next activities. I already setOnItemClickListener in the class, but still won't work. Now my problem is when I click the listview it won't work.
public class TabFragment1_Staff extends Fragment {
ListView lsReport;
ArrayList<HashMap<String, String>> reportlist;
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.activity_tab_fragment1__staff, container, false);
}
#Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
reportlist = new ArrayList<>();
lsReport = getActivity().findViewById(R.id.listReport);
loadReport();
lsReport.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(),AddStatusDialogWindow.class);
Bundle bundle = new Bundle();
Log.e("HANIS",reportlist.get(position).get("reportID"));
bundle.putString("reportID",reportlist.get(position).get("reportID"));
bundle.putString("fullName",reportlist.get(position).get("fullName"));
bundle.putString("icNum",reportlist.get(position).get("icNum"));
bundle.putString("phoneNum",reportlist.get(position).get("phoneNum"));
bundle.putString("Rdate",reportlist.get(position).get("Rdate"));
bundle.putString("Rtime",reportlist.get(position).get("Rtime"));
bundle.putString("timeName",reportlist.get(position).get("timeName"));
bundle.putString("typeVehicle",reportlist.get(position).get("typeVehicle"));
bundle.putString("registrationnum",reportlist.get(position).get("registrationnum"));
bundle.putString("location",reportlist.get(position).get("location"));
bundle.putString("brief",reportlist.get(position).get("brief"));
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}
tabFragment1.xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#+id/listReport"
android:layout_width="match_parent"
android:layout_height="300dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
</ScrollView>
LoadReport class
class LoadReport extends AsyncTask<Void, Void, String> {
#Override
protected String doInBackground(Void... params) {
// Perform api call
}
#Override
protected void onPostExecute(String s) {
reportlist.clear();
// Parse api response and fill in reportlist var
ListAdapter adapter = new CustomList_StatusReport(
getActivity(), reportlist,
R.layout.activity_custom_list__status_report, new String[]
{"reportID","fullName","icNum","phoneNum"}, new int[]
{R.id.tvReport_ID,R.id.tvCompliantName,R.id.tvCompliantIC,R.id.tvCompliantPhone});
lsReport.setAdapter(adapter);
Toast.LENGTH_SHORT).show();
}
}
LoadReport loadReport = new LoadReport();
loadReport.execute();
}
public class CustomList_StatusReport extends SimpleAdapter {
private Context mContext;
public LayoutInflater inflater = null;
public CustomList_StatusReport(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
super(context, data, resource, from, to);
mContext = context;
inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
try {
if (convertView == null)
vi = inflater.inflate(R.layout.activity_custom_list__status_report, null);
HashMap<String, Object> data = (HashMap<String, Object>) getItem(position);
TextView reportID = vi.findViewById(R.id.tvReport_ID);
TextView cName = vi.findViewById(R.id.tvCompliantName);
TextView cIC = vi.findViewById(R.id.tvCompliantIC);
TextView cPhone = vi.findViewById(R.id.tvCompliantPhone);
String id = (String) data.get("reportID");
String name = (String)data.get("fullName");
String ic = (String)data.get("icNum");
String phone = (String)data.get("phoneNum");
reportID.setText(id);
cName.setText(name);
cIC.setText(ic);
cPhone.setText(phone);
}catch (IndexOutOfBoundsException e){}
return vi;
}
In tabFragment1.xml, why you are using the below lines code?
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
Please remove these if not needed and let us know whether this issue exists?
I am new for Android development.
I was trying to implement a custom ArrayAdapter to accept custom object in Android Studio.
I have referenced the source code from some tutorial, but my screen output was improper that the custom object only fill in the TextView which link with the textViewResourceId of ArrayAdapter , but not the custom object's properties fill in all EditText in the layout appropriately.
I tried to remove textViewResourceId parameter in the constructor of ArrayAdapter to fix the problem, but Android Studio returned error - You must supply a resource ID for a TextView
I want the properties of custom object fill in all EditText and no error message be returned, can anyone give me a hint?
Here is my layout:
row_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/row_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<EditText
android:id="#+id/row_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="1dp"
android:layout_gravity="center_horizontal"
android:background="#color/colorWhite"/>
<EditText
android:id="#+id/row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="1dp"
android:layout_gravity="center_horizontal"
android:background="#color/colorWhite"/>
</LinearLayout>
Here is my custom object:
Row.java
public class Row
{
public int RowNo;
public String RowText;
public Row(int no, String text)
{
this.RowNo = no;
this.RowText = text;
}
}
Here is my custom ArrayAdapter:
RowAdapter.java
public class RowAdapter extends ArrayAdapter<Row> {
private final Activity _context;
private final ArrayList<Row> rows;
static class ViewHolder
{
EditText RowNo;
EditText RowText;
}
public RowAdapter(Activity context, ArrayList<Row> rows)
{
super(context,R.layout.row_layout, R.id.row_id ,rows);
this._context = context;
this.rows = rows;
}
public View GetView(int position, View convertView, ViewGroup parent){
ViewHolder holder = null;
if(convertView == null)
{
LayoutInflater inflater = _context.getLayoutInflater();
convertView = inflater.inflate(R.layout.row_layout,parent,false);
holder = new ViewHolder();
holder.RowNo = (EditText)convertView.findViewById(R.id.row_no);
holder.RowText = (EditText)convertView.findViewById(R.id.row_text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.RowNo.setText(rows.get(position).RowNo);
holder.RowText.setText(rows.get(position).RowText);
return convertView;
}
}
Here is my Activity class:
RowActivity.java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.row_list_page);
listView = (ListView)findViewById(R.id.list_view);
ArrayList<Row> rows = new ArrayList<Row>();
rows.add(new Row(1,"Test"));
rows.add(new Row(2,"Test"));
rows.add(new Row(3"Test"));
RowAdapter adapter = new RowAdapter(this,rows);
listView.setAdapter(adapter);
}
Here is working adapter code
public class RowAdapter extends ArrayAdapter<Row> {
private final Activity _context;
private final ArrayList<Row> rows;
public class ViewHolder
{
EditText RowNo;
EditText RowText;
}
public RowAdapter(Activity context, ArrayList<Row> rows)
{
super(context,R.layout.row_layout, R.id.row_id ,rows);
this._context = context;
this.rows = rows;
}
#Override
public View getView(int position, View convertView, ViewGroup parent){
ViewHolder holder = null;
if(convertView == null)
{
LayoutInflater inflater = _context.getLayoutInflater();
convertView = inflater.inflate(R.layout.row_layout,parent,false);
holder = new ViewHolder();
holder.RowNo = (EditText)convertView.findViewById(R.id.row_no);
holder.RowText = (EditText)convertView.findViewById(R.id.row_text);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.RowNo.setText(""+rows.get(position).RowNo);
holder.RowText.setText(rows.get(position).RowText);
return convertView;
}
}
Your getting exception at holder.RowNo.setText(rows.get(position).RowNo);
so replace it with
holder.RowNo.setText(""+rows.get(position).RowNo);
Change with below code:-
RowAdapter.java
public class RowAdapter extends BaseAdapter {
private final Context _context;
private final ArrayList<Row> rows;
public RowAdapter(Context context, ArrayList<Row> rows)
{
this._context = context;
this.rows = rows;
}
#Override
public int getCount() {
return rows.size();
}
#Override
public Object getItem(int position) {
return rows;
}
#Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent){
LayoutInflater inflater = (LayoutInflater) _context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView=inflater.inflate(R.layout.row_layout, null,true);
EditText RowNo = (EditText) rowView.findViewById(R.id.row_no);
EditText RowText = (EditText) rowView.findViewById(R.id.row_text);
RowNo.setText(rows.get(position).RowNo);
RowText.setText(rows.get(position).RowText);
return rowView;
}
}
public View getView (int position, View convertView, ViewGroup parent)
This method is called to get view object.
In your code there is GetView, not getView
change your
public View GetView(int position, View convertView, ViewGroup parent)
with
#Override
public View getView(int position, View convertView, ViewGroup parent)
and
holder.RowNo.setText(rows.get(position).RowNo);
with
holder.RowNo.setText(""+rows.get(position).RowNo);
I want to show my custom ArrayAdapter in a ListFragment with a SlidingTabLayout. Previously I tested the adapter in a normal activity and worked fine, also the SlidingTabLayout worked correctly, but yet the ListFragment show nothing. I get the data from a meteor server and logcat show me the data has been downloaded...
Does anybody have some tips?
This is my Fragment Java Code:
public class MorningFragment extends ListFragment {
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_morning,container,false);
return v;
}
#Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
MedicationTimeAdapter timeAdapter;
timeAdapter = new MedicationTimeAdapter(getActivity(), R.layout.item_time);
setListAdapter(timeAdapter);
}
}
And my Fragment XML Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
My adapter
public class MedicationTimeAdapter extends ArrayAdapter<MedicationTime> implements DataManager.MedicationCallback {
private static final String LOG_TAG = MedicationTimeAdapter.class.getName();
private final int resourceId;
private final Activity activity;
// private List<MedicationEntry> medications = new ArrayList<MedicationEntry>();
public MedicationTimeAdapter(Activity context, int resource) {
super(context, resource);
resourceId = resource;
activity = context;
}
#Override
public void handleMedicationPlan(List<MedicationEntry> medication) {
// ignore
}
#Override
public void handleMedicationTimes(final List<MedicationTime> medicationTimes) {
// TODO Activity möglicherweise nicht mehr aktiv
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
setItems(medicationTimes);
}
});
}
public void setItems(List<MedicationTime> itemList) {
clear();
for (MedicationTime item : itemList) {
add(item);
}
notifyDataSetChanged();
}
#Override
public int getCount() {
return super.getCount();
}
#Override
public View getView(int index, View convertView, ViewGroup parent) {
//data from your adapter
MedicationTime itemData = getItem(index);
if (convertView == null) {
// final LayoutInflater inflater = MHApplication.getLayoutInflater();
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// TODO mit Referenz Parent-Group erzeugen?! (war für ColorFinder notwendig, um die LayoutParams beim Laden zu erhalten)
// convertView = inflater.inflate(resourceId, parent, false);
convertView = inflater.inflate(resourceId, null);
// prepareInflatedView(convertView);
}
setViewContent(index, convertView, itemData);
return convertView;
}
protected void setViewContent(int index, View itemView, MedicationTime itemData) {
final TextView nameView = (TextView) itemView.findViewById(R.id.time_name);
final TextView medicationView = (TextView) itemView.findViewById(R.id.medication);
int nameId = activity.getResources().getIdentifier("time_name." + itemData.getTimeName(), "string", activity.getPackageName());
nameView.setText(activity.getResources().getString(nameId));
nameView.setText(nameId);
StringBuilder medText = new StringBuilder();
List<MedicationTime.Entry> medications = itemData.getMedications();
for (MedicationTime.Entry medication : medications) {
medText.append(medication.getCount());
medText.append(" * ");
medText.append(medication.getMedicationEntry().getSubstance());
medText.append(" (");
medText.append(medication.getMedicationEntry().getTradingName());
medText.append(")\n");
}
medicationView.setText(medText.toString());
}
Edit:
I solved the Problem , i have a Method in my mainActivity to fill the adapter with Data. The problem was i create a new Adapter in my Fragment. So i add a konstruktor in my Fragment class and submitter the Adapter from my mainActivity.
public MorningFragment(MedicationTimeAdapter timeAdapter) {
medicationTimeAdapter = timeAdapter;
}
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_morning,container,false);
setListAdapter(medicationTimeAdapter);
return v;
}
Call handleMedicationTimes(final List<MedicationTime> medicationTimes) with some data, Your code seems is not inflating any data.
I'm attempting to set up a TextAdapter for a String array. Basically it's a drop-down menu that holds a list of strings associated with the size of the item that the user wants to purchase.
private void SetupSpinner(String[] drawables) {
Spinner spinner = (Spinner) view.findViewById(R.id.spinner_sizes);
spinner.setAdapter(new ImageAdapter(getActivity(), R.layout.row, drawables));
}
public class ImageAdapter extends ArrayAdapter<String> {
private String[] drawables;
public ImageAdapter(Context context, int textViewResourceId, String[] drawables) {
super(context, textViewResourceId);
this.drawables = drawables;
}
#Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
return getView(position, convertView, parent);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView view = new TextView(getContext());
view.setText(Integer.parseInt(drawables[position]));
return view;
}
}
I had it working with drawables but that's inefficient. I don't want to make graphics for each of the size options. Anyway, all help greatly appreciated!
Create a xml custom_spinner
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/text_main_seen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="#+id/sub_text_seen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
Then put the spinner in your main xml where you need
<Spinner
android:id="#+id/spinner_show"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100px"
android:drawSelectorOnTop="true" />
Then in your class
public class SpinnerCustomizationActivity extends Activity {
String[] spinnerValues = { "Blur", "NFS", "Burnout","GTA IV", "Racing", };
String[] spinnerSubs = { "Ultimate Game", "Need for Speed", "Ulimate Racing", "Rockstar Games", "Thunder Bolt" };
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner mySpinner = (Spinner) findViewById(R.id.spinner_show);
mySpinner.setAdapter(new MyAdapter(this, R.layout.custom_spinner, spinnerValues)); }
public class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context ctx, int txtViewResourceId, String[] objects)
{
super(ctx, txtViewResourceId, objects); }
#Override
public View getDropDownView(int position, View cnvtView, ViewGroup prnt) { return getCustomView(position, cnvtView, prnt); }
#Override
public View getView(int pos, View cnvtView, ViewGroup prnt)
{
return getCustomView(pos, cnvtView, prnt);
}
public View getCustomView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
View mySpinner = inflater.inflate(R.layout.custom_spinner, parent, false);
TextView main_text = (TextView)mySpinner.findViewById(R.id.text_main_seen);
main_text.setText(spinnerValues[position]);
TextView subSpinner = (TextView)mySpinner.findViewById(R.id.sub_text_seen);
subSpinner.setText(spinnerSubs[position]);
return mySpinner; }
}
}
I want to use custom ListView in extends from ListFragment class. After create new subClass extends from BaseAdapter into current class and set layout to that I get ... has stopped error.
list_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/txt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/txt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"/>
</LinearLayout>
ResivedSMS.java :
public class ResivedSMS extends ListFragment {
private String testArray1[];
private String testArray2[];
private ListView listFragment;
public ResivedSMS() {
testArray1 = new String[] {
"1111111111",
"2222222222",
"3333333333",
"4444444444",
"5555555555",
"6666666666",
};
testArray1 = new String[] {
"AAAAA",
"BBBBB",
"CCCCC",
"DDDDD",
"FFFFF",
"GGGGG",
};
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
listFragment = (ListView) inflater.inflate(
R.layout.list_fragment, container, false);
ViewResivedSMSDetailes customListView = new ViewResivedSMSDetailes(getActivity(),testArray1,testArray2);
listFragment.
setAdapter( customListView );
return listFragment;
}
#Override
public void onListItemClick(ListView list, View v, int position, long id) {
Toast.makeText(getActivity(), getListView().getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
}
class ViewResivedSMSDetailes extends BaseAdapter
{
private LayoutInflater inflater;
private String[] values1;
private String[] values2;
private class ViewHolder {
TextView txt1;
TextView txt2;
}
public ViewResivedSMSDetailes(Context context,String[] values1,String[] values2)
{
this.values1=values1;
this.values2=values2;
inflater = LayoutInflater.from(context);
}
#Override
public int getCount() {
return values1.length;
}
#Override
public Object getItem(int index) {
return values1[index];
}
#Override
public long getItemId(int arg0) {
return arg0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder = null;
if(convertView ==null){
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.list_fragment, null);
holder.txt1 = (TextView)convertView.findViewById(R.id.txt1);
holder.txt2 = (TextView)convertView.findViewById(R.id.txt2);
convertView.setTag(holder);
}
holder = (ViewHolder) convertView.getTag();
holder.txt1.setText(values1[position]);
holder.txt2.setText(values2[position]);
return convertView;
}
}
}
logcat Result:
08-24 10:33:34.675 349-349/ir.tsms E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ClassCastException: android.widget.LinearLayout
at ir.tsms.ResivedSMS.onCreateView(ResivedSMS.java:50)
ResivedSMS.java:50 is:
listFragment = (ListView) inflater.inflate(
R.layout.list_fragment, container, false);
Whats my code problem and how to resolved Thanks?
problem:
inflater.inflate(R.layout.list_fragment, container, false);
You are inflating a LinearLayout not a ListView thus giving you ClassCastException
solution:
Since you are using ListFragment you can directly set the adapter, since ListFragment has its own default ListView. Set the adapter in the onCreate Method.
sample:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewResivedSMSDetailes customListView = new ViewResivedSMSDetailes(getActivity(),testArray1,testArray2);
setListAdapter( customListView ); //call the method if listFragment
}