package com.example.temp; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new vewChange(this); } }
package com.example.temp; import android.content.Context; import android.widget.TextView; public class vewChange { public vewChange(Context context) { // TODO Auto-generated constructor stub TextView tv = (TextView) ((com.example.temp.MainActivity) context).findViewById(R.id.textView1); tv.setText("change"); } }
別パターン
package com.example.temp; import android.widget.TextView; public class vewChange { public vewChange(MainActivity mainActivity) { // TODO Auto-generated constructor stub TextView tv = (TextView) mainActivity.findViewById(R.id.textView1); tv.setText("change"); } }
0 件のコメント:
コメントを投稿