- view plaincopy to clipboardprint?
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <TextView
- android:id="@+id/text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello"
- />
- </LinearLayout>
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <TextView
- android:id="@+id/text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello"
- />
- </LinearLayout>
- view plaincopy to clipboardprint?
- package com.android.tutor;
- import android.app.Activity;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.preference.PreferenceManager;
- import android.widget.TextView;
- public class PreferencesDemo extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- SharedPreferences mPerferences = PreferenceManager
- .getDefaultSharedPreferences(this);
- int counter = mPerferences.getInt("counter", 0);
- TextView mTextView = (TextView)findViewById(R.id.text);
- mTextView.setText("This app has been started " + counter + " times.");
- SharedPreferences.Editor mEditor = mPerferences.edit();
- mEditor.putInt("counter", ++counter);
- mEditor.commit();
- }
- }
- package com.android.tutor;
- import android.app.Activity;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.preference.PreferenceManager;
- import android.widget.TextView;
- public class PreferencesDemo extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- SharedPreferences mPerferences = PreferenceManager
- .getDefaultSharedPreferences(this);
- int counter = mPerferences.getInt("counter", 0);
- TextView mTextView = (TextView)findViewById(R.id.text);
- mTextView.setText("This app has been started " + counter + " times.");
- SharedPreferences.Editor mEditor = mPerferences.edit();
- mEditor.putInt("counter", ++counter);
- mEditor.commit();
- }
- }
联系客服