0
我有什麼:用buttonadapter一個GridView。這裏的適配器的代碼古怪的圖形錯誤在android系統
public class ButtonAdapter extends BaseAdapter {
static List<Button> button = new ArrayList<Button>();
private Context mContext;
// Gets the context so it can be used later
public ButtonAdapter(Context c) {
mContext = c;
}
public int getCount() {
return my.package.names.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return position;
}
public View getView(int position,
View convertView, ViewGroup parent) {
if (convertView == null) {
button.add(new Button(mContext));
button.get(position).setLayoutParams(new GridView.LayoutParams(85, 85));
button.get(position).setPadding(8, 8, 8, 8);
button.get(position).setOnClickListener(new MyOnClickListener(position));
}
else {
}
button.get(position).setText(my.package.names[position]); // names is an array of strings
button.get(position).setTextColor(Color.BLACK);
button.get(position).setBackgroundResource(*Drawable here*);
return button.get(position);
}
}
問題:當觸摸屏幕上的按鈕,然後移動手指uperright或uperleft或DOWNLEFT或徹頭徹尾的角落我的按鈕調整大小,並隨着這個(以下imagege): OnClickListener類,很簡單
public class MyOnClickListener implements OnClickListener
{
private final int position;
int i;
public MyOnClickListener(int position)
{
this.position = position;
}
public void onClick(View v)
{
// Preform a function based on the position
for(i=0; i<9; i++){
if(this.position == i){
mypackagemyclass.flipper.setDisplayedChild(i); //viewflipper
mypackagemyclass.slider.open(); //sliding drawer
}
}
}}
我試圖用一個imageadapter,同樣的問題一樣。在模擬器和真實設備上。我到處搜索,似乎沒有人有過這個問題。我能用這個做什麼?