package com.example.com;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.widget.TextView;import java.util.Random; public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState){ TextView tv; String s, r = ""; int start = 6,end = 14; super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv = (TextView) findViewById(R.id.tvInfo2); s = getResources().getString(R.string.info); for(int i = 0;i<end - start;i++) r=r+"*"; s =s.replace(s.substring(start, end),r); tv.setText(s); } //就是这行改背景颜色的没反应 public class colorss extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); int bgc[] = {R.color.gp1, R.color.bg2, R.color.bg3, R.color.bg4, R.color.bg5}; Random r= new Random(); int i = r.nextInt(bgc.length); getWindow().setBackgroundDrawableResource(bgc[i]);} @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } }
- 3 回答
- 0 关注
- 1352 浏览
添加回答
举报
0/150
提交
取消