TelaCadastroRestauranteDAO.java - 它不会延长活动
和
TelaCadastroRestaurante.java - 它会延长活动
在我的第一堂课 TelaCadastroRestauranteDAO.java 中,我有一个字符串 restauranteParseIdString ,它有一个值。我希望将此字符串传递给其他类 TelaCadastroRestaurante.java 。
我无法使用Intent,因为我的..DAO类没有扩展活动,所以我无法导入Intent(至少,我认为这是问题) < / p>
public class TelaCadastroRestauranteDAO {
private static ParseObject restauranteParse;
private static String restauranteParseIdString = restauranteParse.getObjectId();
private static ProgressDialog dialog;
private static AlertDialog.Builder builderaction;
...
}
和
public class TelaCadastroRestaurante extends Activity {
private Restaurante rest;
private Button proximoButton;
private EditText nomeRestauranteEditText, emailRestauranteEditText, telefoneRestauranteEditText;
private String nomeRestauranteString, emailRestauranteString, telefoneRestauranteString, idRestaurante;
private String voceTemCertezaCadastrarRestaurante = "Você tem certeza que deseja cadastrar o restaurante: ";
private Context contexThisClass = TelaCadastroRestaurante.this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tela_cadastro_restaurante);
// i want get the string right here
if(checkwifi()){
setUpComponents();
dealButtons();
}
}
}
答案 0 :(得分:1)
因为restauranteParseIdString
是static
字段,所以要在其他类使用类名中访问它,如:
String strDAO=TelaCadastroRestauranteDAO.restauranteParseIdString;
并将restauranteParseIdString
声明为public
以便在其他类中访问:
public static String restauranteParseIdString = restauranteParse.getObjectId();