2016-05-19 7 views
0

Ich versuche, eine GPS-App mit einer Kontaktliste, um mit anderen Menschen zu verknüpfen, ich bin neu in Android Studio, so dass ich nicht sicher bin, wie das zu lösen. Ich habe die Karte und GPS zuerst erstellt, und sie funktionieren gut, aber jetzt die Kontaktliste hat einen Fehler.Android-Kontaktliste, Fehler in Asynctask und setAdapter

Meine Kontaktliste ist in einem Popup-Menü mit der Taste Kontakte auf der Homepage zugegriffen werden kann, aber jetzt gibt immer einen Fehler, wenn die contactslist

Der Fehler zuzugreifen versuchen, i aus dem Protokoll habe ist: java. lang.NullPointerException: Versuch zum virtuellen Methode 'VOID android.widget.ListView.setAdapter (android.widget.ListAdapter)' auf einer null-Objekt aufzurufen Referenz

Hier ist die mainactivity

package com.example.pow.gpsapp; 
 

 
import android.app.Activity; 
 
import android.content.Context; 
 
import android.graphics.Point; 
 
import android.graphics.drawable.BitmapDrawable; 
 
import android.location.Address; 
 
import android.location.Geocoder; 
 
import android.support.v4.app.FragmentActivity; 
 
import android.os.Bundle; 
 
import android.view.Gravity; 
 
import android.view.LayoutInflater; 
 
import android.view.View; 
 
import android.widget.Button; 
 
import android.widget.EditText; 
 
import android.widget.LinearLayout; 
 
import android.widget.PopupWindow; 
 
import android.widget.RelativeLayout; 
 
import android.widget.AdapterView; 
 
import android.widget.ListView; 
 
import android.widget.SearchView; 
 
import android.widget.Toast; 
 
import android.content.ContentResolver; 
 
import android.database.Cursor; 
 
import android.net.Uri; 
 
import android.os.AsyncTask; 
 
import android.provider.ContactsContract; 
 
import android.provider.MediaStore; 
 
import android.util.Log; 
 

 

 
import com.google.android.gms.maps.CameraUpdate; 
 
import com.google.android.gms.maps.CameraUpdateFactory; 
 
import com.google.android.gms.maps.GoogleMap; 
 
import com.google.android.gms.maps.OnMapReadyCallback; 
 
import com.google.android.gms.maps.SupportMapFragment; 
 
import com.google.android.gms.maps.model.LatLng; 
 
import com.google.android.gms.maps.model.MarkerOptions; 
 
import com.example.pow.gpsapp.SelectUser; 
 
import com.example.pow.gpsapp.SelectUserAdapter; 
 

 
import java.io.IOException; 
 
import java.util.ArrayList; 
 
import java.util.List; 
 

 

 
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 
 

 
    private GoogleMap mMap; 
 
    ArrayList<SelectUser> selectUsers; 
 
    List<SelectUser> temp; 
 
    ListView listView; 
 
    Cursor phones, email; 
 

 
    ContentResolver resolver; 
 

 
    SelectUserAdapter adapter; 
 

 
    @Override 
 
    protected void onCreate(Bundle savedInstanceState) { 
 
     super.onCreate(savedInstanceState); 
 
     setContentView(R.layout.activity_maps); 
 
     SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
 
       .findFragmentById(R.id.map); 
 
     mapFragment.getMapAsync(this); 
 
     Button btnContact= (Button) findViewById(R.id.btnContact); 
 
     btnContact.setOnClickListener(new View.OnClickListener() { 
 
      @Override 
 
      public void onClick(View v){ 
 
       showSortPopup(MapsActivity.this,null); 
 
      } 
 
     }); 
 
    } 
 
    private void showSortPopup(final Activity context, Point p) 
 
    { 
 
     selectUsers = new ArrayList<SelectUser>(); 
 
     resolver = this.getContentResolver(); 
 
     listView = (ListView) findViewById(R.id.contacts_list); 
 

 
     phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC"); 
 
     LoadContact loadContact = new LoadContact(); 
 
     loadContact.execute(); 
 

 

 
     // Inflate the popup_layout.xml 
 
     RelativeLayout viewGroup = (RelativeLayout) context.findViewById(R.id.ContactLayout); 
 
     LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
 
     View layout = layoutInflater.inflate(R.layout.contactlist, viewGroup); 
 

 
     // Creating the PopupWindow 
 
     final PopupWindow popup = new PopupWindow(context); 
 
     popup.setContentView(layout); 
 
     popup.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); 
 
     popup.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); 
 
     popup.setFocusable(true); 
 

 
     // Some offset to align the popup a bit to the left, and a bit down, relative to button's position. 
 
     int OFFSET_X = -20; 
 
     int OFFSET_Y = 95; 
 

 
     // Clear the default translucent background 
 
     popup.setBackgroundDrawable(new BitmapDrawable()); 
 
     // Displaying the popup at the specified location, + offsets. 
 
     popup.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); 
 

 
     Button Back = (Button) layout.findViewById(R.id.btnBack); 
 
     Back.setOnClickListener(new View.OnClickListener() { 
 

 
      @Override 
 
      public void onClick(View v) { 
 
       popup.dismiss(); 
 
      } 
 
     }); 
 

 

 
    } 
 
    public void onZoom(View view) 
 
    { 
 
     if(view.getId() == R.id.btnzoomin) 
 
     { 
 
      mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null); 
 
     } 
 
     if(view.getId() == R.id.btnzoomout) 
 
     { 
 
      mMap.animateCamera(CameraUpdateFactory.zoomTo(8), 2000, null); 
 
     } 
 
    } 
 

 
    public void onSearch(View view) 
 
    { 
 
     EditText location_tf = (EditText)findViewById(R.id.txtAddress); 
 
     String location = location_tf.getText().toString(); 
 
     List<Address> addressList = null; 
 
     if(location != null || location.equals("")) 
 
     { 
 
      Geocoder geocoder = new Geocoder(this); 
 
      try { 
 
       addressList = geocoder.getFromLocationName(location, 1); 
 
      } catch (IOException e) { 
 
       e.printStackTrace(); 
 
      } 
 
      Address address = addressList.get(0); 
 
      LatLng latLng = new LatLng(address.getLatitude() , address.getLongitude()); 
 
      mMap.addMarker(new MarkerOptions().position(latLng).title("Marker")); 
 
      mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15)); 
 
     } 
 
    } 
 

 

 
    @Override 
 
    public void onMapReady(GoogleMap googleMap) { 
 
     mMap = googleMap; 
 
     mMap.setMyLocationEnabled(true); 
 
     LatLng coordinate = new LatLng(1.3468, 103.9326); 
 
     CameraUpdate location = CameraUpdateFactory.newLatLngZoom(coordinate, 15); 
 
     mMap.animateCamera(location); 
 
    } 
 
    class LoadContact extends AsyncTask<Void, Void, Void> { 
 
     @Override 
 
     protected void onPreExecute() { 
 
      super.onPreExecute(); 
 

 
     } 
 

 
     @Override 
 
     protected Void doInBackground(Void... voids) { 
 
      // Get Contact list from Phone 
 

 
      if (phones != null) { 
 
       Log.e("count", "" + phones.getCount()); 
 
       if (phones.getCount() == 0) { 
 
        Toast.makeText(MapsActivity.this, "No contacts in your contact list.", Toast.LENGTH_LONG).show(); 
 
       } 
 

 
       while (phones.moveToNext()) { 
 

 
        String id = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID)); 
 
        String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); 
 
        String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); 
 
        String EmailAddr = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA2)); 
 
        String image_thumb = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI)); 
 

 

 
        SelectUser selectUser = new SelectUser(); 
 
        selectUser.setName(name); 
 
        selectUser.setPhone(phoneNumber); 
 
        selectUser.setEmail(id); 
 
        selectUser.setCheckedBox(false); 
 
        selectUsers.add(selectUser); 
 
       } 
 
      } else { 
 
       Log.e("Cursor close 1", "----------------"); 
 
      } 
 
      //phones.close(); 
 
      return null; 
 
     } 
 

 
     @Override 
 
     protected void onPostExecute(Void aVoid) { 
 
      super.onPostExecute(aVoid); 
 
      adapter = new SelectUserAdapter(selectUsers, MapsActivity.this); 
 
      listView.setAdapter(adapter); 
 

 
      // Select item on listclick 
 
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
 
       @Override 
 
       public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
 

 
        Log.e("search", "here---------------- listener"); 
 

 
        SelectUser data = selectUsers.get(i); 
 
       } 
 
      }); 
 

 
      listView.setFastScrollEnabled(true); 
 
     } 
 
    } 
 

 
    @Override 
 
    protected void onStop() { 
 
     super.onStop(); 
 
     phones.close(); 
 
    } 
 
}

AndroidManifest

<?xml version="1.0" encoding="utf-8"?> 
 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 
    package="com.example.pow.gpsapp"> 
 
    <uses-permission android:name="android.permission.INTERNET" /> 
 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 
 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
 

 
    <application 
 
     android:allowBackup="true" 
 
     android:icon="@mipmap/ic_launcher" 
 
     android:label="@string/app_name" 
 
     android:supportsRtl="true" 
 
     android:theme="@style/AppTheme"> 
 

 
     <!-- 
 
      The API key for Google Maps-based APIs is defined as a string resource. 
 
      (See the file "res/values/google_maps_api.xml"). 
 
      Note that the API key is linked to the encryption key used to sign the APK. 
 
      You need a different API key for each encryption key, including the release key that is used to 
 
      sign the APK for publishing. 
 
      You can define the keys for the debug and release targets in src/debug/ and src/release/. 
 
     --> 
 
     <meta-data 
 
      android:name="com.google.android.geo.API_KEY" 
 
      android:value="@string/google_maps_key" /> 
 

 
     <activity 
 
      android:name=".MapsActivity" 
 
      android:label="@string/title_activity_maps"> 
 
      <intent-filter> 
 
       <action android:name="android.intent.action.MAIN" /> 
 

 
       <category android:name="android.intent.category.LAUNCHER" /> 
 
      </intent-filter> 
 
     </activity> 
 
    </application> 
 

 
</manifest>

SelectUser.java

package com.example.pow.gpsapp; 
 

 

 
public class SelectUser { 
 
    String name; 
 

 

 
    public String getPhone() { 
 
     return phone; 
 
    } 
 

 
    public void setPhone(String phone) { 
 
     this.phone = phone; 
 
    } 
 

 
    String phone; 
 

 
    public Boolean getCheckedBox() { 
 
     return checkedBox; 
 
    } 
 

 
    public void setCheckedBox(Boolean checkedBox) { 
 
     this.checkedBox = checkedBox; 
 
    } 
 

 
    Boolean checkedBox = false; 
 

 
    public String getName() { 
 
     return name; 
 
    } 
 

 
    public void setName(String name) { 
 
     this.name = name; 
 
    } 
 

 
    String email; 
 

 
    public String getEmail() { 
 
     return email; 
 
    } 
 

 
    public void setEmail(String email) { 
 
     this.email = email; 
 
    } 
 

 

 
}

Select Adapter.java

package com.example.pow.gpsapp; 
 

 
import android.annotation.TargetApi; 
 
import android.content.Context; 
 
import android.graphics.Bitmap; 
 
import android.graphics.BitmapFactory; 
 
import android.os.Build; 
 
import android.util.Log; 
 
import android.view.LayoutInflater; 
 
import android.view.View; 
 
import android.view.ViewGroup; 
 
import android.widget.BaseAdapter; 
 
import android.widget.CheckBox; 
 
import android.widget.ImageView; 
 
import android.widget.TextView; 
 

 
import com.example.pow.gpsapp.R; 
 
import com.example.pow.gpsapp.SelectUser; 
 

 
import java.util.ArrayList; 
 
import java.util.List; 
 
import java.util.Locale; 
 

 
public class SelectUserAdapter extends BaseAdapter { 
 

 
    public List<SelectUser> _data; 
 
    private ArrayList<SelectUser> arraylist; 
 
    Context _c; 
 
    ViewHolder v; 
 

 
    public SelectUserAdapter(List<SelectUser> selectUsers, Context context) { 
 
     _data = selectUsers; 
 
     _c = context; 
 
     this.arraylist = new ArrayList<SelectUser>(); 
 
     this.arraylist.addAll(_data); 
 
    } 
 

 
    @Override 
 
    public int getCount() { 
 
     return _data.size(); 
 
    } 
 

 
    @Override 
 
    public Object getItem(int i) { 
 
     return _data.get(i); 
 
    } 
 

 
    @Override 
 
    public long getItemId(int i) { 
 
     return i; 
 
    } 
 

 
    public View getView(int i, View convertView, ViewGroup viewGroup) { 
 
     View view = convertView; 
 
     if (view == null) { 
 
      LayoutInflater li = (LayoutInflater) _c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
 
      view = li.inflate(R.layout.contactview, null); 
 
      Log.e("Inside", "here--------------------------- In view1"); 
 
     } else { 
 
      view = convertView; 
 
      Log.e("Inside", "here--------------------------- In view2"); 
 
     } 
 

 
     v = new ViewHolder(); 
 

 
     v.title = (TextView) view.findViewById(R.id.name); 
 
     v.check = (CheckBox) view.findViewById(R.id.check); 
 
     v.phone = (TextView) view.findViewById(R.id.no); 
 

 
     final SelectUser data = (SelectUser) _data.get(i); 
 
     v.title.setText(data.getName()); 
 
     v.check.setChecked(data.getCheckedBox()); 
 
     v.phone.setText(data.getPhone()); 
 

 

 

 
     view.setTag(data); 
 
     return view; 
 
    } 
 

 
    // Filter Class 
 
    public void filter(String charText) { 
 
     charText = charText.toLowerCase(Locale.getDefault()); 
 
     _data.clear(); 
 
     if (charText.length() == 0) { 
 
      _data.addAll(arraylist); 
 
     } else { 
 
      for (SelectUser wp : arraylist) { 
 
       if (wp.getName().toLowerCase(Locale.getDefault()) 
 
         .contains(charText)) { 
 
        _data.add(wp); 
 
       } 
 
      } 
 
     } 
 
     notifyDataSetChanged(); 
 
    } 
 
    static class ViewHolder { 
 
     ImageView imageView; 
 
     TextView title, phone; 
 
     CheckBox check; 
 
    } 
 
}

activitymaps.xml

<LinearLayout 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="wrap_content" 
 
    xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:orientation="vertical" 
 
    android:weightSum="1"> 
 

 
    <RelativeLayout 
 
    android:layout_width="match_parent" 
 
    android:layout_height="wrap_content"> 
 

 

 
     <EditText 
 
      android:layout_width="133dp" 
 
      android:layout_height="wrap_content" 
 
      android:id="@+id/txtAddress" 
 
      android:layout_marginLeft="0dp" 
 
      android:layout_alignParentTop="true" 
 
      android:layout_alignParentStart="true" 
 
      android:layout_toStartOf="@+id/btn_Address" /> 
 

 
     <Button 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Search" 
 
     android:id="@+id/btn_Address" 
 
     android:layout_gravity="right" 
 
     android:onClick="onSearch" 
 

 
      android:layout_alignParentTop="true" 
 
      android:layout_alignParentEnd="true" /> 
 

 
    <Button 
 
     style="?android:attr/buttonStyleSmall" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="^" 
 
     android:id="@+id/btnzoomin" 
 
     android:onClick="onZoom" 
 

 
     android:layout_below="@+id/txtAddress" 
 
     android:layout_alignParentStart="true" 
 
     android:contextClickable="false" /> 
 

 
     <Button 
 
      style="?android:attr/buttonStyleSmall" 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content" 
 
      android:text="v" 
 
      android:id="@+id/btnzoomout" 
 
      android:onClick="onZoom" 
 

 
      android:layout_below="@+id/txtAddress" 
 
      android:layout_toEndOf="@+id/btnzoomin" /> 
 

 
     <Button 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content" 
 
      android:text="Contact" 
 
      android:id="@+id/btnContact" 
 
      android:layout_below="@+id/txtAddress" 
 
      android:layout_toEndOf="@+id/btnzoomout" /> 
 

 
    </RelativeLayout> 
 

 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
 
    xmlns:tools="http://schemas.android.com/tools" 
 
    android:id="@+id/map" 
 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="fill_parent" 
 
    tools:context="com.example.pow.gpsapp.MapsActivity" /> 
 

 
</LinearLayout>

contactlist.xml

<?xml version="1.0" encoding="utf-8"?> 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
 
    android:background="@android:color/white" 
 
    android:id="@+id/ContactLayout"> 
 

 
    <ListView 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:id="@+id/contacts_list" 
 
     android:layout_centerHorizontal="true" 
 
     android:layout_above="@+id/btnBack" /> 
 
    <Button 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Back" 
 
     android:id="@+id/btnBack" 
 
     android:layout_alignParentBottom="true" 
 
     android:layout_centerHorizontal="true" /> 
 
</RelativeLayout>

contactview.xml

<?xml version="1.0" encoding="utf-8"?> 
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="match_parent" 
 
    android:orientation="vertical"> 
 

 
    <LinearLayout 
 
     android:layout_width="match_parent" 
 
     android:layout_height="wrap_content" 
 
     android:orientation="horizontal" 
 
     android:layout_margin="5dp" 
 
     android:weightSum="3"> 
 

 
     <LinearLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="wrap_content" 
 
      android:orientation="horizontal" 
 
      android:layout_margin="5dp" 
 
      android:weightSum="3"> 
 

 

 
      <LinearLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:orientation="vertical" 
 
       android:layout_weight="2.6" 
 
       android:layout_margin="5dp" 
 
       android:paddingLeft="10dp" 
 
       android:layout_gravity="center"> 
 

 
       <TextView 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:id="@+id/name" 
 
        android:text="User name" 
 
        android:textSize="18dp" /> 
 

 
       <TextView 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:id="@+id/no" 
 
        android:layout_marginTop="10dp" 
 
        android:text="Phone no." 
 
        android:textSize="18dp" /> 
 

 
      </LinearLayout> 
 

 
      <LinearLayout 
 
      android:layout_weight="0" 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content" 
 
      android:layout_gravity="right|center" 
 
      android:gravity="center" 
 
      android:visibility="gone" 
 
      android:orientation="horizontal"> 
 

 
      <CheckBox 
 
       android:layout_width="50dp" 
 
       android:layout_height="50dp" 
 
       android:id="@+id/check" /> 
 

 
      </LinearLayout> 
 

 
     </LinearLayout> 
 

 
    </LinearLayout> 
 
</LinearLayout>

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference 
 
                      at com.example.pow.gpsapp.MapsActivity$LoadContact.onPostExecute(MapsActivity.java:202) 
 
                      at com.example.pow.gpsapp.MapsActivity$LoadContact.onPostExecute(MapsActivity.java:158) 
 
                      at android.os.AsyncTask.finish(AsyncTask.java:632) 
 
                      at android.os.AsyncTask.access$600(AsyncTask.java:177) 
 
                      at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) 
 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
 
                      at android.os.Looper.loop(Looper.java:145) 
 
                      at android.app.ActivityThread.main(ActivityThread.java:6075) 
 
                      at java.lang.reflect.Method.invoke(Native Method) 
 
                      at java.lang.reflect.Method.invoke(Method.java:372) 
 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

+0

machen Listview öffentlichen und letzten Mai kann helfen! – pooyan

+0

'ListView' wird initialisiert, dann wird' AsyncTask' ausgeführt. Hmmm. Haben Sie versucht, Logs in 'doInBackground()' oder 'onPostExecute()' für die Größe Ihrer 'selectUsers' zu platzieren? –

+0

@pooyan Das ListView ist bereits eine globale Variable, wenn er es "final" macht, wird er es nicht mehr ändern können. –

Antwort

0

In Ihrem activitymaps.xml Sie nicht hav e ListView mit contacts_list ID.

bearbeiten

nach dem, was ich in Ihrem Code zu sehen glaube, ich Ihr Problem gelöst werden, wenn Sie Ihre „showSortPopup“ als Gebrüll ersten Zeilen ändern:

 // Inflate the popup_layout.xml 
    RelativeLayout viewGroup = (RelativeLayout) context.findViewById(R.id.ContactLayout); 
    LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View layout = layoutInflater.inflate(R.layout.contactlist, viewGroup); 

    selectUsers = new ArrayList<SelectUser>(); 
    resolver = this.getContentResolver(); 
    listView = (ListView) layout.findViewById(R.id.contacts_list); 

    phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC"); 
    LoadContact loadContact = new LoadContact(); 
    loadContact.execute(); 
+0

Vermeiden Sie Ausrufezeichen, da es in der Community ziemlich unhöflich erscheint. –

+0

Das stimmt. Es gibt keine contacts_list in activitymaps.xml Ich stimme zu @pooyan – Adnan

+0

@RyanPow Können Sie Ihre 'activity_maps.xml' veröffentlichen? Da wir in Ihrem Beitrag nur die 'contacts_list ListView' in Ihrer' contactlist.xml' sehen können. –

Verwandte Themen