Skip to content

Instantly share code, notes, and snippets.

@wheeliechamp
Created April 30, 2020 12:53
Show Gist options
  • Save wheeliechamp/9c74c1449acfa596e5b85bebf10b5151 to your computer and use it in GitHub Desktop.
Save wheeliechamp/9c74c1449acfa596e5b85bebf10b5151 to your computer and use it in GitHub Desktop.
Activity以外から更新とSharedPreferencesの使い方
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
TextView textview1 = findViewById(R.id.textView1);
textview1.setText("かきくけこ");
final TextChange text_change = new TextChange(context);
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
text_change.textChange();
}
});
}
public static void testTest() {
Log.d("@@@@@::", "testTest");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment