I developed one app , in that i have to display map. latitude and longitude i got from the api-web-service.
I that have one Custom base adapter to display raw file of all data.
My remaining data set very well.
But when i used fragment in my raw file , i got the error.
in this line,
vi = inflater.inflate(R.layout.raw_file, null);
also trying it by :
vi = inflater.inflate(R.layout.chat_raw_3, parent , true);
or
vi = inflater.inflate(R.layout.chat_raw_3, parent , false);
or
vi = inflater.inflate(R.layout.chat_raw_3, null, false);
in getView(...) method.
in raw_file.xml file i add fragment like following :
<fragment
android:id="@+id/map_sender"
android:layout_width="150dp"
android:layout_height="150dp"
class="com.google.android.gms.maps.SupportMapFragment"
/>
I got following error in logcat :
android.view.InflateException: Binary XML file line #113: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
.
.
.
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.fragment" on path: DexPathList
The important thing is that it work fine on my another activity ( that not used inflate raw file ) but while using custom adapter raw file it giving above error.
I search many option online, but not got the solution, So please any one help me to solve-out this question.
EDIT
My Entire Class Structure Like following :
public class My_Activity extends ListActivity {
// all variable declaration here
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screen);
initialize();
}
private void initialize()
{
// all fields initialize here
// set value to custom adapter
new setAdapter().execute();
}
public class setAdapter extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
// other things
return "yes";
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
adpt = new MyAdapter(getApplicationContext(), arr);
setListAdapter(adpt);
adpt.notifyDataSetChanged();
getListView().setSelection(adpt.getCount() - 1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
private class MyAdapter extends BaseAdapter implements LocationListener {
ArrayList<HashMap<String, String>> arr;
HashMap<String, String> map;
Context c;
LayoutInflater inflater;
private GoogleMap map_sender, map_reciver;
double latitude;
double longitude;
public MyAdapter(Context activity, ArrayList<HashMap<String, String>> arr) {
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
c = activity;
arr = arr;
}
@Override
public int getCount() {
return arr.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null)
// I got error in following line ========== error below line =======
vi = inflater.inflate(R.layout.raw_file, null);
map_sender = ((MapFragment) getFragmentManager().findFragmentById(R.id.map_sender))
.getMap();
TextView tv_room_name = (TextView) vi.findViewById(R.id.tv_room_name);
TextView tv_raw_date = (TextView) vi.findViewById(R.id.tv_raw_date);
HashMap<String, String> product = new HashMap<String, String>();
product = arr.get(position);
String fiile_type_locations = product.get("file_type_location").toString();
String file_beam_latitudes = product.get("file_latitude").toString();
String file_beam_longitudes = product.get("file_longitude").toString();
tv_room_name.setVisibility(View.VISIBLE);
tv_room_name.setText("");
if (!fiile_type_locations.equals("")) {
// here i set map
}
return vi;
}
@Override
public void onLocationChanged(Location location) {
}
}
My raw_file.xml is look like following :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/rl_raw_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:id="@+id/tv_raw_date"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text="Date" />
<TextView
android:id="@+id/tv_room_name"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:singleLine="true"
android:text="senderName"
android:textSize="14sp"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/contentWithBackground_sender_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:visibility="gone">
<!-- binary xml file inflating following first line -->
<fragment
android:id="@+id/map_sender"
android:layout_width="150dp"
android:layout_height="150dp"
class="com.google.android.gms.maps.MapFragment"
/>
<!-- <fragment
android:id="@+id/map_sender"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="150dp"
android:layout_height="150dp" />-->
</LinearLayout>
</LinearLayout>