package com.jleo.war3;
import android.app.Activity;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TableLayout.LayoutParams;
public class UnitInDetailActivity extends Activity {
public static final String UNITNAME = "UNITNAME";
public static final String UNITINFO = "UNITINFO";
static final String UNITIMGID = "UNITIMGID";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.unitindetail);
TableLayout tl = (TableLayout) this
.findViewById(R.id.unitindetailtable);
Bundle unitNameBundle = this.getIntent().getBundleExtra(
UnitInDetailActivity.UNITINFO);
int unitImgId = unitNameBundle.getInt(UnitInDetailActivity.UNITIMGID);
String[] fileNames = ResourceDict.lookup(unitImgId);
for (int i = 0; i < fileNames.length; i += 2) {
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
String leftFileName = fileNames[i];
SingleSoundingButton ibLeft = new SingleSoundingButton(this);
ibLeft.setSoundId(this.getResources().getIdentifier("com.jleo.war3:raw/"+leftFileName, null,null));
ibLeft.setBackgroundDrawable(this.getResources().getDrawable(
R.drawable.humbtn));
ibLeft.setText(leftFileName);
ibLeft.setTextColor(ColorStateList.valueOf(0x99ffff80));
ibLeft.setPadding(20, 5, 20, 5);
tr.addView(ibLeft);
if (i < fileNames.length) {
String rightFileName = fileNames[i + 1];
SingleSoundingButton ibRight = new SingleSoundingButton(this);
ibRight.setSoundId(this.getResources().getIdentifier("com.jleo.war3:raw/"+rightFileName, null,null));
ibRight.setBackgroundDrawable(this.getResources().getDrawable(
R.drawable.humbtn));
ibRight.setPadding(20, 5, 20, 5);
ibRight.setText(rightFileName);
ibRight.setTextColor(ColorStateList.valueOf(0x99ffff80));
tr.addView(ibRight);
}
tl.addView(tr, new TableLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
}
}
sssssss
最新推荐文章于 2021-09-19 09:31:22 发布