Pregunta

Estoy tratando de actualizar mi lista de listas personalizadas )adapter;

Editar:

Cuando hago clic en un elemento en ListView, está llamando a la pantalla de Goruntuleactivity y creando el método de Encreate (asumo que está creando ...) y luego llamo a un método de goruntuleactivity y el LayPutinFlater está en esta actividad.

listeleactivity.java

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View item,
                    int position, long id) {

                onClickPosition = position;

                final Intent intent = new Intent(ListeleActivity.this,
                        GoruntuleActivity.class);
                startActivity(intent);

                goruntuleNesnesi.isSetListRefresh(onClickPosition , issetlist);
            }
        });

y está llamando el método de goruntuleacttivity.java

  public void isSetListRefresh(int onClickPosition, ArrayList<String> issetlist )
    {
        issetlist.set(onClickPosition, "false");
        setRecentOrSeen(issetlist);
        ListviewRefresh();
    }

    public void ListviewRefresh() 
    {
        LayoutInflater mLInflater = LayoutInflater.from(this);

        ListViewAdapter adapter = new ListViewAdapter(
                getApplicationContext(), getKimdenList(), getKonuList(), getRecentOrSeen() ,
                mLInflater);
        adapter.Remove();

    }

y ahora me está dando otra excepción ...

05-18 16:25:22.073: E/AndroidRuntime(807): FATAL EXCEPTION: main
05-18 16:25:22.073: E/AndroidRuntime(807): java.lang.IllegalStateException: System services not available to Activities before onCreate()
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.app.Activity.getSystemService(Activity.java:3526)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.view.LayoutInflater.from(LayoutInflater.java:171)
05-18 16:25:22.073: E/AndroidRuntime(807):  at com.mobil.eposta.GoruntuleActivity.ListviewRefresh(GoruntuleActivity.java:160)
05-18 16:25:22.073: E/AndroidRuntime(807):  at com.mobil.eposta.GoruntuleActivity.isSetListRefresh(GoruntuleActivity.java:155)
05-18 16:25:22.073: E/AndroidRuntime(807):  at com.mobil.eposta.ListeleActivity$1.onItemClick(ListeleActivity.java:137)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.widget.ListView.performItemClick(ListView.java:3382)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.os.Handler.handleCallback(Handler.java:587)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.os.Looper.loop(Looper.java:123)
05-18 16:25:22.073: E/AndroidRuntime(807):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-18 16:25:22.073: E/AndroidRuntime(807):  at java.lang.reflect.Method.invokeNative(Native Method)
05-18 16:25:22.073: E/AndroidRuntime(807):  at java.lang.reflect.Method.invoke(Method.java:521)
05-18 16:25:22.073: E/AndroidRuntime(807):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-18 16:25:22.073: E/AndroidRuntime(807):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-18 16:25:22.073: E/AndroidRuntime(807):  at dalvik.system.NativeStart.main(Native Method)

¿Fue útil?

Solución

De los registros de errores, parece que getApplicationContext () está devolviendo NULL.¿Cuándo estás llamando goruntuleNesnesi.ListviewRefresh();?¿Está en el ondrato (...)?Si es así, es así, puede ser su problema ya que getApplicationContext(...) devolverá NULL hasta que se realice la inicialización de onCreate(...).

Editar : Miré a través de la pila de traza un poco más y parece que está llamando a ListViewRefresh en un botón.¿Ha intentado usar this en lugar de getApplicationContext (...)?

Editar 2 : intente esto:

ListViewAdapter adapter = new ListViewAdapter(this, getKimdenList(), getKonuList(), getRecentOrSeen() ,mLInflater); 

Aunque, creo que es May sufre del mismo problema porque la actividad aún no se ha dibujado en la pantalla y no se ha inicializado, no se puede inflar las opiniones sobre ella.Pruébalo y iremos desde allí.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top