Y
Y
ywitodenasuby2018-10-01 01:00:58
Android
ywitodenasuby, 2018-10-01 01:00:58

Why doesn't text in fragment change?

Basically, nothing happens.
The activity has a Fragment. Its Layout can be changed settingsLayout = R.layout.settings_layout1; . On this Layout, I cannot reach the EditText and change its properties, for example, text. just nothing happens. And etPrice is not null . What could be the problem?

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Log.d(TAG, "-----------onCreateView");
        // Inflate the layout for this fragment
        int settingsLayout = R.layout.fragment_ad_settings;
        Log.d(TAG, targetCategory);
        switch (targetCategory){
            case "541":
            case "70":
            case "540":
                settingsLayout = R.layout.settings_layout1;
                // Цена, Состояние, Размер, Частное лицо / Бизнес
                break;
            case "5414":
            case "888":
                //
                break;
            default:
                settingsLayout = R.layout.fragment_ad_settings;
                break;
        }
  
  ...
  
    View view = inflater.inflate(settingsLayout, container, false);
                                    EditText etPrice = (EditText) view.findViewById(R.id.etPrice);
                                    etPrice.setText("ffffffffffs");
          return inflater.inflate(settingsLayout, container, false);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2018-10-01
@ywitodenasuby

 The layout is created twice because. It is necessary to return view;  correct in the last line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question