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 關注
- 1400 瀏覽
添加回答
舉報
0/150
提交
取消