我有listview的BaseAdapter类,这个列表视图中有两个按钮。单击此按钮时,我想要打开或关闭渐变抽屉。全屏我的申请图片http://tinypic.com/view.php?pic=wtjg2s&s=8#.VFngCvmsXtt
我的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 :(得分: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();
}
});
}
}