我想用透明背景显示警告对话框.我的警报对话框代码是:
AlertDialog.Builder imageDialog = new AlertDialog.Builder(SubProducts.this);
LayoutInflater inflater = (LayoutInflater)SubProducts.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.cust_toast_layout,(ViewGroup)findViewById(R.id.linearLayout2));
ImageView image = (ImageView)layout.findViewById(R.id.imageView1);
image.setPadding(0, 20, 0, 0);
imgLoader.DisplayImage(image_url, loader, image);
TextView tprice=(TextView)layout.findViewById(R.id.pricetext);
tprice.setText("$ "+pricedouble);
TextView tvdprh=(TextView)layout.findViewById(R.id.textView1);
tvdprh.setText(prohd);
WebView wv=(WebView)layout.findViewById(R.id.webview);
Spanned sub=Html.fromHtml(descp);
String s = "<html><head><style type='text/css' >@font-face {font-family:'myfont';src: url('file:///android_asset/fonts/ABeeZee-Regular.ttf');}body {margin:0px;color:000000;font-family: myfont;"
+ "text-align: justify;}</style></head><body>"
+ sub
+ "</body></html>";
wv.loadDataWithBaseURL("", s, "text/html", "utf-8", null);
wv.setVerticalScrollBarEnabled(true);
wv.setBackgroundColor(Color.TRANSPARENT);
wv.setPadding(5, 25, 5, 0);
ImageView imgcartl=(ImageView)layout.findViewById(R.id.imageView2);
imgcartl.setBackgroundResource(R.drawable.cartlines);
ImageView brobutton=(ImageView)layout.findViewById(R.id.imageView3);
brobutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intentlabl …
Run Code Online (Sandbox Code Playgroud) 我开发应用程序以将动态数据添加到多个表视图.结构如下.
我在onPostExecute中的代码是:
protected void onPostExecute(List<String> results){
int ind,i = 0;
ScrollView sv=null;
TableLayout tl=null;
TableRow tr = null;
int mjsonlength=results.size();
if(results!=null){
TableLayout indextl=(TableLayout)findViewById(R.id.indextablelayout);
TableRow indextr=new TableRow(SubProducts.this);
//indext1.moveToFirst();
LinearLayout llt=(LinearLayout)findViewById(R.id.alltablell);
//for(int f=0;f<mjsonlength;f++){
for( ind=0;ind<indextitle.size();ind++)
{
TextView indextv=new TextView(SubProducts.this);
indextv.setBackgroundResource(R.drawable.greenbg);
indextv.setHeight(25);
indextv.setWidth(50);
indextv.setId(6);
indextv.setTextColor(Color.WHITE);
indextv.setText(indextitle.get(ind));
indextv.setPadding(20,10,6,3);
indextr.addView(indextv);
indextl.addView(indextr,6);
sv=new ScrollView(SubProducts.this);
tl=new TableLayout(SubProducts.this);
for( i=0;i<mjsonlength;i++){
tr=new TableRow(SubProducts.this);
if(ind==i) {
RelativeLayout rl=new RelativeLayout(SubProducts.this);
Resources res = getResources(); //resource handle
rl.setBackgroundResource(R.drawable.prd_box);
RelativeLayout.LayoutParams newParams1 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
image=new ImageView(SubProducts.this);
image.setLayoutParams(newParams1);
image.setId(1);
image.setImageBitmap(bmp);
image.setPadding(5, 20, …
Run Code Online (Sandbox Code Playgroud) Android版本:4.2
我正在开发一个Android应用程序.我需要随机生成可绘制文件夹中的图像.在我的drawable中我有45个不同名字的图像.我的xml代码是:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Run Code Online (Sandbox Code Playgroud)
我尝试过这段代码:
ImageView img=(ImageView)findViewById(R.id.imageView1);
Random rand = new Random();
int rndInt = rand.nextInt(52) + 1;
String drawableName = "photo"+ rndInt;
int resID = getResources().getIdentifier(drawableName, "drawable", getPackageName());
img.setImageResource(resID);
Run Code Online (Sandbox Code Playgroud)
但有了这个代码,我需要改变我的形象名称photo1
,photo2
......我不想这样做.
有关如何实施它的任何建议?谢谢.