Adapterview de dinamik buton olutururken hata alıyorum yardımcı olabilirmisiniz 2 gündür çözmeye çalışıyorum bi sonuca varamadım . contextleri view yerine activity yapmayı denedim yine olmadı

MESAJADAPTER.JAVA KODLARI


package com.proje.adapter;

import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast;

import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.NetworkImageView; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import com.proje.AppController; import com.proje.R; import com.proje.model.Mesaj;

import java.util.HashMap; import java.util.List; import java.util.Map;

public class MesajAdapter extends BaseAdapter { private Activity activity; private LayoutInflater inflater; private List<itiraf> mesajItems; ImageLoader imageLoader = AppController.getInstance().getImageLoader();

public MesajAdapter(Activity activity, List<Mesaj> itirafItems) {
    this.activity = activity;
    this.mesajItems = mesajItems;
}

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

@Override
public Object getItem(int location) {
    return MesajItems.get(location);
}

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

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

    if (inflater == null)
        inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null)
        convertView = inflater.inflate(R.layout.mesaj_liste, null, false);

    if (imageLoader == null)
        imageLoader = AppController.getInstance().getImageLoader();
    NetworkImageView profilResmi = (NetworkImageView) convertView
            .findViewById(R.id.profil_resmi);
    TextView konu = (TextView) convertView.findViewById(R.id.mesajkonu);
    TextView icerik = (TextView) convertView.findViewById(R.id.mesajicerik);
    TextView begeni = (TextView) convertView.findViewById(R.id.mesajbegeni);
    TextView tarih = (TextView) convertView.findViewById(R.id.mesajtarih);

    // Her bir itiraf satırı için bilgi alınıyor
    final Itiraf m = mesajItems.get(position);

    // Profil resmi
    profilResmi.setImageUrl(m.getProfilResmi(), imageLoader);

    // Konu
    konu.setText(m.getKonu());

    //İçerik
    icerik.setText(m.getIcerik());

    // Begeni
    begeni.setText(String.valueOf(m.getBegeni()));

    // Tatih
    tarih.setText(String.valueOf(m.getTarih()));

    Button myButton1 = new Button(convertView.getContext());
    final LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.mesaj_layout) ;  // butonun eklenecegi layout tanimlandi
    myButton1.setId(1);   // butona id atandi
    myButton1.setX(100);  // butona x koordinati verildi
    myButton1.setY(50);  // butona y koordinati verildi
    myButton1.setText("DinamikButon");
    final int id=myButton1.getId();
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(150,80);  // butonun boyutlari verildi
    myButton1 = ((Button) convertView.findViewById(id));
    ll.addView(myButton1, lp);  __Hata veren satır__
    myButton1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {  // butonun click olayi
            Toast.makeText(view.getContext(),
                    "Button a tiklandi", Toast.LENGTH_SHORT)
                    .show();
        }
    });

    return convertView;
}

}

HATA KODLARI


08-16 07:38:05.381 1198-1198/com.proje E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NullPointerException

at android.view.ViewGroup.addViewInner(ViewGroup.java:3377)

at android.view.ViewGroup.addView(ViewGroup.java:3249)

at android.view.ViewGroup.addView(ViewGroup.java:3225)

at com.proje.adapter.MesajAdapter.getView(MesajAdapter.java:104)

at android.widget.AbsListView.obtainView(AbsListView.java:2267)

at android.widget.ListView.makeAndAddView(ListView.java:1769)

at android.widget.ListView.fillDown(ListView.java:672)

at android.widget.ListView.fillFromTop(ListView.java:733)

at android.widget.ListView.layoutChildren(ListView.java:1608)

at android.widget.AbsListView.onLayout(AbsListView.java:2102)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:596)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.widget.FrameLayout.onLayout(FrameLayout.java:448)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1187)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.widget.FrameLayout.onLayout(FrameLayout.java:448)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)

at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)

at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.widget.FrameLayout.onLayout(FrameLayout.java:448)

at android.view.View.layout(View.java:13754)

at android.view.ViewGroup.layout(ViewGroup.java:4362)

at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)

at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)

at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)

at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)

at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)

at android.view.Choreographer.doCallbacks(Choreographer.java:555)

at android.view.Choreographer.doFrame(Choreographer.java:525)

at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)

at android.os.Handler.handleCallback(Handler.java:615)

at android.os.Handler.dispatchMessage(Handler.java:92)

at android.os.Looper.loop(Looper.java:137)

at android.app.ActivityThread.main(ActivityThread.java:4745)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:511)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

at dalvik.system.NativeStart.main(Native Method)

XML KODLARI +++++++++++++++++++

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/list_row_selector" android:padding="8dp" android:id="@+id/mesaj_layout">
<!-- Profil Resmi -->
<com.android.volley.toolbox.NetworkImageView
    android:id="@+id/profil_resmi"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_marginRight="8dp" />

<!-- Konu -->
<TextView
    android:id="@+id/mesajkonu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/profil_resmi"
    android:layout_toRightOf="@+id/profil_resmi"
    android:textSize="@dimen/mesajkonu"
    android:textStyle="bold" />

<!-- İçerik -->
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/mesajicerik"
    android:layout_below="@+id/mesajkonu"
    android:layout_toRightOf="@+id/profil_resmi"
    android:layout_toEndOf="@+id/profil_resmi" />

<!-- Begeni -->
<TextView
    android:id="@+id/mesajbegeni"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="@dimen/mesajbegeni"
    android:layout_alignRight="@+id/mesajkonu"
    android:layout_alignEnd="@+id/mesajkonu"
    android:layout_below="@+id/profil_resmi"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<!-- Tarih -->
<TextView
    android:id="@+id/mesajtarih"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:textColor="@color/tarih"
    android:textSize="@dimen/mesajtarih" />
</linearlayout>

soruldu: 16 Ağu, 03:54

Tayfun's gravatar image

Tayfun
01
cevap kabul oranı: 0%

Bu soruya ilk cevap veren sen ol!
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:

×819
×5

Soruldu: 16 Ağu, 03:54

Görüntüleme: 148 kez

Son güncelleme: 16 Ağu, 03:54

powered by BitNami OSQA