İyi günler custom listview oluşturup fragmentte kullanıcam sonra bu fragmenti mainactivity içine çağıracam kodun neresinde hata var sürekli aynı yerde hata veriyor

Kisi.class

`public class Kisi { private String isim; private boolean kadinMi;

public Kisi(String isim, boolean kadinMi) {
    super();
    this.isim = isim;
    this.kadinMi = kadinMi;
}

@Override
public String toString() {
    return isim;
}

public String getIsim() {
    return isim;
}

public void setIsim(String isim) {
    this.isim = isim;
}

public boolean isKadinMi() {
    return kadinMi;
}

public void setKadinMi(boolean kadinMi) {
    this.kadinMi = kadinMi;
}

}`

OzelAdapter.class

public class OzelAdapter extends BaseAdapter { private LayoutInflater mInflater; private List<kisi> mKisiListesi;

public OzelAdapter(Activity activity, List<Kisi> kisiler) {
    //XML'i alıp View'a çevirecek inflater'ı örnekleyelim
    mInflater = (LayoutInflater) activity.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    //gösterilecek listeyi de alalım
    mKisiListesi = kisiler;
}

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

@Override
public Kisi getItem(int position) {
    //şöyle de olabilir: public Object getItem(int position)
    return mKisiListesi.get(position);
}

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View satirView;

    satirView = mInflater.inflate(R.layout.satir_layout, null);
    TextView textView =
            (TextView) satirView.findViewById(R.id.isimsoyisim);
    ImageView imageView =
            (ImageView) satirView.findViewById(R.id.simge);

    Kisi kisi = mKisiListesi.get(position);

    textView.setText(kisi.getIsim());

    return satirView;
}

}

yok.java fragment

package com.example.serkan.myapplication;

import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView;

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

/* * Created by serkan on 15.08.2016. / public class yok extends ListFragment{

List<Kisi> kisiler=new ArrayList<Kisi>();
public static final String ARG_SECTION_NUMBER = "section_number";

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root=inflater.inflate(R.layout.gg,container,false);

    return root;
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    int num = getArguments().getInt(ARG_SECTION_NUMBER);

    kisiler.add(new Kisi("Ahmet Yılmaz", false));
    kisiler.add(new Kisi("Ayşe Küçük", true));
    kisiler.add(new Kisi("Fatma Bulgurcu", true));
    kisiler.add(new Kisi("İzzet Altınmeşe", false));
    kisiler.add(new Kisi("Melek Subaşı", true));
    kisiler.add(new Kisi("Selim Serdilli",false));
    kisiler.add(new Kisi("Halil İbrahim",false));

    ListView listemiz = (ListView)getActivity(). findViewById(R.id.liste);
    OzelAdapter adaptorumuz=new OzelAdapter(getActivity(), kisiler);
    listemiz.setAdapter(adaptorumuz);

}

}

satir_layot.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
    android:id="@+id/simge"
    android:layout_width="48dp"
    android:layout_height="48dp" />

<TextView
    android:id="@+id/isimsoyisim"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</linearlayout>

soruldu: 15 Ağu, 09:33

husmen123's gravatar image

husmen123
03
cevap kabul oranı: 0%

Hatayı (logcat çıktısını) da buraya yazarsanız daha kolay yardımcı oluruz.

(15 Ağu, 09:40) ersinyildiz ersinyildiz's gravatar image

ekledim teşekkürler uyardığınız için

(15 Ağu, 11:12) husmen123 husmen123's gravatar image

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.example.serkan.mb5.yok.onCreateView(yok.java:36)

permanent link

cevaplandı: 15 Ağu, 11:14

husmen123's gravatar image

husmen123
03
cevap kabul oranı: 0%

hatanın tam halini bizimle paylaşırsan daha iyi yardımcı olabiliriz. Ama yinede bi tahmin yürüteyim..

ListView listemiz = (ListView)getActivity(). findViewById(R.id.liste);

buradaki ListView nesnesi hangi layout içeridinde?

View root=inflater.inflate(R.layout.gg,container,false);

eğer gg.xml içerisinde değil ise bu hatayı alabilirsin.

permanent link

cevaplandı: 15 Ağu, 11:30

umonn's gravatar image

umonn
80013
cevap kabul oranı: 25%

gg.xml in içinde

(15 Ağu, 13:24) husmen123 husmen123's gravatar image

Sİlip tekrar yüklememe rağmen düzelmedi.Çıktı tam olarak şu

                                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.serkan.myapplication/com.example.serkan.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2397)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2449)
                                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                                  at android.os.Looper.loop(Looper.java:193)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5353)
                                                                                  at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                  at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
                                                                                  at dalvik.system.NativeStart.main(Native Method)
                                                                               Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
                                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
                                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                                  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                                                                                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                                  at com.example.serkan.myapplication.MainActivity.onCreate(MainActivity.java:11)
                                                                                  at android.app.Activity.performCreate(Activity.java:5387)
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2449) 
                                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                  at android.os.Looper.loop(Looper.java:193) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5353) 
                                                                                  at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                  at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
                                                                                  at dalvik.system.NativeStart.main(Native Method) 
                                                                               Caused by: java.lang.NullPointerException
                                                                                  at com.example.serkan.myapplication.yok.onCreateView(yok.java:36)
                                                                                  at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
                                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
                                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1264)
                                                                                  at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1366)
                                                                                  at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2409)
                                                                                  at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
                                                                                  at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:374)
                                                                                  at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:33)
                                                                                  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75)
                                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
                                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                                  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                  at com.example.serkan.myapplication.MainActivity.onCreate(MainActivity.java:11) 
                                                                                  at android.app.Activity.performCreate(Activity.java:5387) 
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351) 
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2449) 
                                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                  at android.os.Looper.loop(Looper.java:193) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5353) 
                                                                                  at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                  at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
                                                                                  at dalvik.system.NativeStart.main(Native Method)
permanent link

cevaplandı: 15 Ağu, 13:24

husmen123's gravatar image

husmen123
03
cevap kabul oranı: 0%

at com.example.serkan.myapplication.yok.onCreateView(yok.java:36) Bu satırda hangi değerin null geldiğini debug edip bulabilirseniz hata da büyük ölçüde ortaya çıkacak.

(16 Ağu, 02:48) ersinyildiz ersinyildiz's gravatar image

bu ne.. çözülmez bu.

(16 Ağu, 02:51) yunus yunus's gravatar image

Çözümü buldum Özeladaptörü ArrayList'en extend ettim

(16 Ağu, 04:40) husmen123 husmen123's gravatar image
Cevabınız
toggle preview

Bu soruyu takip et

E-Posta üzerinden:

Üyelik girişi yaptıktan sonra abonelik işlemlerini yapabilirsiniz

RSS üzerinden:

Cevaplar

Cevaplar ve Yorumlar

Yazı Formatlama

  • *italic* ya da _italic_
  • **bold** ya da __bold__
  • link:[text](http://url.com/ "başlık")
  • resim?![alt text](/path/img.jpg "başlık")
  • liste: 1. Foo 2. Bar
  • temel HTML etiketleri de kullanılabilir

Bu sorunun etiketleri:

×1,077
×818

Soruldu: 15 Ağu, 09:33

Görüntüleme: 171 kez

Son güncelleme: 16 Ağu, 04:40

powered by BitNami OSQA