`
ggyyleo
  • 浏览: 46825 次
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

sssssss

阅读更多
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));
		}
	}
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics