これを実装すると、以下のエラーが発生します。私が理解していないことは、EditText
入力フィールドはどのように静的コンテンツですか?私がここで欠けているかもしれない非常に基本的なものかもしれません。このテキストフィールドの静的コンテンツはどのように編集しますか?
Error:(28, 32) error: non-static method findViewById(int) cannot be referenced from a static context
コード:
package com.example.kheriaa.meme_fragments_v1;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
public class TopSectionFragment extends Fragment {
private EditText TopText;
private EditText BottomText ;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frags_layout, container, false);
TopText = (EditText) View.findViewById(R.id.TopText);
//return super.onCreateView(inflater, container, savedInstanceState);
return v;
}
}
でこれ
TopText = (EditText) View.findViewById(R.id.TopText);
を交換しては、このですか?見ていない? – supersayan@supersayanはい、Viewのインスタンスがvであるため、v.findViewById(R.id.TopText)を使用する必要があります。 –
@supersayan私は説明を追加しました – rafsanahmad007