在用户点击左侧的绿色按钮后,如何向单元格3和5添加矩形(边框)?
现在我只是打印"警告"如下所示。我想在单元格3和5上制作一个特定的正方形。
@Override
protected ArrayList<CellVO> transformRowCells(Node node)
{
String symbol = Commons.xml_getAttribute(node, "symbol");
String samount = StringExtra.stringAsMathUserfriendlyWithString( Commons.xml_getAttribute(node, "samount"), symbol );
String srate = Commons.xml_getAttribute(node, "srate");
String spl = StringExtra.stringAsRoundedWithString( Commons.xml_getAttribute(node, "spl") );
String lamount = StringExtra.stringAsMathUserfriendlyWithString( Commons.xml_getAttribute(node, "lamount"), symbol );
String lrate = Commons.xml_getAttribute(node, "lrate");
String lpl = StringExtra.stringAsRoundedWithString( Commons.xml_getAttribute(node, "lpl") );
int lplColor = CommonsParitem.colorForStringFromPL2(lpl);
int splColor = CommonsParitem.colorForStringFromPL2(spl);
if(lplColor == 0) lplColor = CommonsParitem.defaultTextColorGray();
if(splColor == 0) splColor = CommonsParitem.defaultTextColorGray();
//Log.d("custom", node + ", spl: "+spl+", lpl: "+lpl);
CellVO cell0 = new CellVO(16, symbol, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
CellVO cell1 = new CellVO(13, lamount, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
CellVO cell2 = new CellVO(13, lrate, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
CellVO cell3 = new CellVO(12, lpl, Gravity.RIGHT | Gravity.CENTER_VERTICAL, lplColor);
CellVO cell4 = new CellVO(12, samount, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
CellVO cell5 = new CellVO(14, srate, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
CellVO cell6 = new CellVO(13, spl, Gravity.RIGHT | Gravity.CENTER_VERTICAL, splColor);
// icon cell
CellVO cell7 = new CellVO();
cell7.widthPercent = 5;
cell7.imgIcon = Commons.isTablet() ? R.drawable.tb_table_cell_btn_x : (didPozEdited(node) ? R.drawable.poz_acikislem_edit1 : R.drawable.poz_acikislem_edit0);
cell7.setCustomEventListener(new CellVO.OnIconTapListener() {
@Override
public void onIconTap(View v) {
Log.v("Info","Warning");
}
});
ArrayList<CellVO> cells = new ArrayList<CellVO>();
cells.add(cell7);
cells.add(cell0);
cells.add(cell1);
cells.add(cell2);
cells.add(cell3);
cells.add(cell4);
cells.add(cell5);
cells.add(cell6);
return cells;
}
我的XML文件:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:orderInCategory="100"
android:showAsAction="never" />
答案 0 :(得分:0)
使用此rectangle.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#ff0000"/>
</shape>
在绿色按钮onClick()
TextView t1 = (TextView) findViewById(R.id.rowtext3);
t1.setBackgroundResource(R.drawable.rectangle);