在我的测试应用程序中,我有一个带有一些片段的活动。当用户从片段中选择一个项目时,该项目将加载到另一个片段上。
但是片段的edittext并没有显示之前设置的文本。如果我使用其 getText 打印日志,则会打印文本。但在屏幕上,edittext 是空的。
只是为了测试,我将文本的颜色和背景与文本一起更改。但我看不出有什么不同。
我设置新值的代码:
private void initValues(GeneralInformation generalInformation) {
clientSalesOrderNumberEdit.setText(generalInformation.clientSalesOrderNumber);
representativeSalesOrderNumberEdit.setText(generalInformation.representativeSalesOrderNumber);
salesOrderNoteEdit.setText(generalInformation.salesOrderNote);
revenueNoteEdit.setText(generalInformation.revenueNote);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
this.view = inflater.inflate(R.layout.sales_order_general_fragment);
salesOrderEdit = (EditText) view.findViewById(R.id.sales_order_general_id);
salesOrderTypeEdit = (InstantAutoCompleteTextView) view.findViewById(R.id.sales_order_general_type);
emissionDateText = (EditText) view.findViewById(R.id.sales_order_general_emission);
baseDateText = (TextView) view.findViewById(R.id.sales_order_general_base);
revenueAntecipatedEdit = (CheckBox) view.findViewById(R.id.sales_order_general_revenue_antecipated);
clientSalesOrderNumberEdit = (EditText) view.findViewById(R.id.sales_order_general_number_client);
representativeSalesOrderNumberEdit = (EditText) view.findViewById(R.id.sales_order_general_number_representative);
salesChannelTypeEdit = (InstantAutoCompleteTextView) view.findViewById(R.id.sales_order_general_sales_channel);
salesOrderNoteEdit = (EditText) view.findViewById(R.id.sales_order_general_note);
revenueNoteEdit = (EditText) view.findViewById(R.id.sales_order_general_revenue_note);
salesOrderNoteEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter(250) });
revenueNoteEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter(250) });
salesOrderEdit.setEnabled(false);
emissionDateText.setEnabled(false);
GeneralInformation generalInformation = ((SalesOrderGeneralActivity)getActivity()).getSalesOrderGeneralInfo();
updateEnabled(((SalesOrderGeneralActivity)getActivity()).isDraft());
initValues(generalInformation);
Button btnGeral = (Button) view.findViewById(R.id.menu_lateral_btn_geral);
btnGeral.setOnClickListener(this);
Button btnCliente = (Button) view.findViewById(R.id.menu_lateral_btn_cliente);
btnCliente.setOnClickListener(this);
Button btnTransportePagamento = (Button) view.findViewById(R.id.menu_lateral_btn_transporte_pagamento);
btnTransportePagamento.setOnClickListener(this);
Button btnIncluirItem = (Button) view.findViewById(R.id.menu_lateral_btn_add_item);
btnIncluirItem.setOnClickListener(this);
Button btnListItens = (Button) view.findViewById(R.id.menu_lateral_btn_list_itens);
btnListItens.setOnClickListener(this);
btnGeral.setBackgroundResource(R.drawable.menu_lateral_ativado_geral);
btnGeral.setTextColor(getResources().getColor(R.color.lateral_menu_text_selected));
return this.view;
}
如果我设置一个明确的文本,例如:
salesOrderNoteEdit.setText("fooooo");
它的作品,字符串显示
任何提示?