2014-11-05 98 views
-1

我有用於listview的BaseAdapter類,兩個按鈕位於此列表視圖中。當點擊這個按鈕時,我想打開或關閉slinding抽屜。全屏我的應用程序的圖片http://tinypic.com/view.php?pic=wtjg2s&s=8#.VFngCvmsXttAndroid BaseAdapter ListView按鈕單擊以訪問其他活動項目

我baseadapter類

public class SCariList extends BaseAdapter{ 

    NCari cari = new NCari(); 
    Context context; 
    Activity activity; 

    private LayoutInflater inflater; 
    private List<NCari> cariList; 

    public SCariList(Activity activity , List<NCari> cariler,Context con){ 

     inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

     cariList = cariler; 

     context = con; 

    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     // TODO Auto-generated method stub 

     View vi = convertView; 

     if(convertView == null) 
     // vi = inflater.inflate(R.layout.test_satir, parent,false); 

     vi = inflater.inflate(R.layout.test_satir, null); 
     final TextView textViewtest = (TextView) vi.findViewById(R.id.test_satir); 
     final TextView textView2 = (TextView) vi.findViewById(R.id.test_satir2); //calışıyor 

     //Bu ikisini kapaltık 
     final ImageButton btn_gecmis = (ImageButton) vi.findViewById(R.id.btn_gecmis); 
     final ImageButton btn_duzenle = (ImageButton) vi.findViewById(R.id.btn_duzenle); 

     /*Burada bir terslik var*/ 
     final Button btn_gecmis1 = (Button) vi.findViewById(R.id.btn_evrak1); 
     final Button btn_duzenle1 = (Button) vi.findViewById(R.id.btn_gecmis1); 

     //Buraya istediğimiz gibi ekleyebilir. 
     NCari nCari = cariList.get(position); 
     /*istediğimiz değerlerle set ettik*/ 
     textViewtest.setText(String.valueOf(nCari.getID())); 
     textView2.setText(nCari.getAd().toString()); 

     /*Butona basınca SlidingDrawer calışması 
     * sdwAlisFatura adı*/ 

     /*YENİ EVRAK*/ 
     btn_gecmis1.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 

       cari.setCariID(Integer.valueOf(textViewtest.getText().toString())); 
       cari.setAd(textView2.getText().toString()); 

       Intent intent = new Intent(context, SEvrak.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

       intent.putExtra("Cari", cari); 

       context.startActivity(intent); 

      } 
     }); 

     btn_duzenle1.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 

      // Toast.makeText(context, "Oldu", 10).show(); 

      } 
     }); 

     return vi; 

    } 

} 

和活動班組長

public class AlisCari extends Activity { 

    Context context=this ; 

    EditText arama; 
    ListView cariListView; 
    TextView tvSatir; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.alis_cari); 

     arama = (EditText) findViewById(R.id.txtAlisFaturaArama); 

     cariListView = (ListView) findViewById(R.id.lstAlisSiparisCari); 

     CariVeritaban cariVeritaban = new CariVeritaban(getApplicationContext()); 

     List<NCari> cariler = cariVeritaban.getCariListe(); 

     SCariList sCariList = new SCariList(AlisCari.this, cariler, context); 

     cariListView.setAdapter(sCariList); 

     arama.addTextChangedListener(txtizleyici); 

    } 

回答

0

使用此代碼:

public class SCariList extends BaseAdapter{ 

    NCari cari = new NCari(); 
    Context context; 
    Activity activity; 

    private LayoutInflater inflater; 
    private List<NCari> cariList; 

    public SCariList(Activity activity , List<NCari> cariler,Context con){ 

     inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

     cariList = cariler; 

     context = con; 

    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     // TODO Auto-generated method stub 

     View vi = convertView; 

     if(convertView == null) 
     // vi = inflater.inflate(R.layout.test_satir, parent,false); 

     vi = inflater.inflate(R.layout.test_satir, null); 
     final TextView textViewtest = (TextView) vi.findViewById(R.id.test_satir); 
     final TextView textView2 = (TextView) vi.findViewById(R.id.test_satir2); //calışıyor 

     //Bu ikisini kapaltık 
     final ImageButton btn_gecmis = (ImageButton) vi.findViewById(R.id.btn_gecmis); 
     final ImageButton btn_duzenle = (ImageButton) vi.findViewById(R.id.btn_duzenle); 

     /*Burada bir terslik var*/ 
     final Button btn_gecmis1 = (Button) vi.findViewById(R.id.btn_evrak1); 
     final Button btn_duzenle1 = (Button) vi.findViewById(R.id.btn_gecmis1); 

     //Buraya istediğimiz gibi ekleyebilir. 
     NCari nCari = cariList.get(position); 
     /*istediğimiz değerlerle set ettik*/ 
     textViewtest.setText(String.valueOf(nCari.getID())); 
     textView2.setText(nCari.getAd().toString()); 

     /*Butona basınca SlidingDrawer calışması 
     * sdwAlisFatura adı*/ 

     /*YENİ EVRAK*/ 
     btn_gecmis1.setOnClickListener(new Listener1()); 

     btn_duzenle1.setOnClickListener(new Listener2()); 

     return vi; 

    } 

class Listener1 implements OnClickListener 
{ 
@Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
    cari.setCariID(Integer.valueOf(textViewtest.getText().toString())); 
       cari.setAd(textView2.getText().toString()); 

       Intent intent = new Intent(context, SEvrak.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

       intent.putExtra("Cari", cari); 

       context.startActivity(intent); 

      } 
     }); 
} 
class Listener2 implements OnClickListener 
{ 
@Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 

      // Toast.makeText(context, "Oldu", 10).show(); 

      } 
     }); 
} 

} 
+0

我認爲你不能明白他問這個問題?請在發帖之前閱讀問題。 – 2014-11-05 08:52:19

+0

雖然此代碼塊可能會回答該問題,請嘗試通過相關說明和代碼改進您的答案。請參閱http://stackoverflow.com/help/how-to-answer – SMR 2015-02-18 07:42:52

相關問題