首页 文章

将currentt活动传递给超级[等待]

提问于
浏览
0

如何将 ActivityProfile 传递给 Set class(超类)?

注意:set类中的 activity 字段是 ActivityProfile

public class Set extends AppCompatActivity {
  protected View v_change_profile = null;
  protected TextView txtTitle;

  private Activity activity ;

  public Set(Activity activity) {
    this.activity= activity; 
    LayoutInflater inflater = activity.getLayoutInflater();
    v_change_profile = inflater.inflate(R.layout.edit_profile_dialog, null);

    txtTitle = v_change_profile.findViewById(R.id.txtTitle);
  }

// ********* **

public class ActivityProfile extends Set {
    //...
}

1 回答

  • 0

    您可以通过 super. 修饰符访问变量或调用超类的函数

    比如:在 Set 类中,声明一个像这样的变量 private ActivityProfile profile .

    ActivityProfile 类中, super.profile = this 如果要分配它

相关问题