schwiz
By: a guest | Feb 9th, 2010 | Syntax:
Java | Size: 1.91 KB | Hits: 121 | Expires: Never
public class ItemList extends LinearLayout implements OnClickListener {
public Rect outline;
LinkedList<Item> items;
WorkSheet gameRef;
super(context, attrs);
gameRef = (WorkSheet) context;
items = new LinkedList<Item>();
//setOrientation(VERTICAL);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// TODO Auto-generated method stub
super.onSizeChanged(w, h, oldw, oldh);
outline = rectFactory(2, 2, getWidth() -2 , getHeight() -2);
}
@Override
public void onClick
(View v
) {
addItem("THIS is a test for my list");
}
// @Override
// protected void onLayout(boolean changed, int l, int t, int r, int b) {
// // TODO Auto-generated method stub
// super.onLayout(changed, l, t, r, b);
// if(items != null){
// for(int i = 0; i < items.size(); i++){
// addViewInLayout(items.get(i), -1, items.get(i).getLayoutParams());
// }
// }
// }
Item newItem = new Item(gameRef);
newItem.setText(desc);
newItem.setTextSize(13.0f);
newItem.
setTextColor(Color.
BLACK);
newItem.
setBackgroundColor(Color.
WHITE);
newItem.setLayoutParams(new LayoutParams(outline.width() - 2, LayoutParams.WRAP_CONTENT));
items.add(newItem);
addView(newItem);
}
@Override
protected void onDraw
(Canvas canvas
) {
canvas.drawRect(outline,Pallet.getInstance().blackOutline);
super.onDraw(canvas);
}
public Rect rectFactory(int x, int y, int width, int height){
return new Rect(x,y,x+width-1, y+height-1);
}
private class Item extends TextView implements OnLongClickListener{
super(context);
// TODO Auto-generated constructor stub
}
@Override
public boolean onLongClick
(View v
) {
// TODO Auto-generated method stub
return false;
}
}
}