零碎知识

SharedPreferences 使用(保存 一个TYPESIZE的例子)
1:初始化  final SharedPreferences sp=this.getSharedPreferences("TYPESIZE", Context.MODE_PRIVATE);
    int size =sp.getInt("SIZE", 17);
           如果第一次执行,SIZE就为17
2:保存数据:Editor  ee=ss.edit();
      ee.putInt("SIZE", seekbar.getProgress()+10);
      ee.commit();
3:读取数据:
             final SharedPreferences ss=this.getSharedPreferences("TYPESIZE", Context.MODE_PRIVATE);
      int size=ss.getInt("SIZE", 17);
            如果读取出错就为17

Dialog的显示:
              创建一个dialog.xml
           dialog=new Dialog(this);
         LayoutInflater inflate=LayoutInflater.from(this);
  View dialogView=inflate.inflate(R.layout.dialog, null);
                dialog.setContentView(dialogView);
  dialog.setTitle("我的dialog");
  dialog.show();
Android .txt的读取以及字体设置:

  InputStream is=this.getResources().openRawResource(R.raw.cet201112yw);
     BufferedReader br=new BufferedReader(new InputStreamReader(is));
     StringBuffer sb=new  StringBuffer();
     String buffer=null;
     try {
   while((buffer=br.readLine())!=null){
    sb.append(buffer);
    sb.append("\n");
   }
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }


        textViewEnglish.setText(sb.toString());读取完了
有三种字体:
        textViewEnglish.setTypeface(Typeface.SANS_SERIF);
 typeface.setTypeface(Typeface.MONOSPACE);
 textViewEnglish.setTypeface(Typeface.SERIF);
MediaPlay播放:
创建一个类 public class MyService extends Service
定义 public static MediaPlayer mp=null;
在onStart 方法 写入mp.start();就可以

在Androidmanifest的anctivity中设置
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

ScrollView可以实现 上下滑动屏幕效果
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

你可能感兴趣的:(零碎知识)