Android 单击按钮时如何向单元格添加边框?
在用户单击左侧的绿色按钮后,如何向单元格3和5添加矩形边框 现在我正在打印警告,如下所示。我想在3号和5号单元格上画一个正方形Android 单击按钮时如何向单元格添加边框?,android,mouseevent,touch-event,Android,Mouseevent,Touch Event,在用户单击左侧的绿色按钮后,如何向单元格3和5添加矩形边框 现在我正在打印警告,如下所示。我想在3号和5号单元格上画一个正方形 @Override protected ArrayList<CellVO> transformRowCells(Node node) { String symbol = Commons.xml_getAttribute(node, "symbol"); String samount = StringEx
@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" />
使用此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>
我可以不在.xml文件中写入任何内容而通过编程编写一些内容吗?据我所知,这是正确的方法,并且减少了代码。嘿,你找到解决问题的方法了吗?没有。我试图做的是,一旦我点击绿色按钮,我想标记单元格3和5,一旦我触摸到标记,我想对此采取行动单间牢房我可以吗?是的你可以。。。在绿色按钮onClick和单元格onClick中检查我的答案。
TextView t1 = (TextView) findViewById(R.id.rowtext3);
t1.setBackgroundResource(R.drawable.rectangle);