0

ここまでは自分のコードです。私はこれが初めてAndroidスタジオを使用しようとしていることを言及する必要があります。あなたはすべてをお勧めする可能性のある図書は、同様に素晴らしいことだ:これはエラーを取り除くが、新しいものを生み出してしまったフラグメント内のオートコンプリートテキストビューにfindViewByIdを使用する方法

public class master_profile extends Fragment { 

    AutoCompleteTextView autoCompleteTextView; 
    public master_profile() { 
    // Required empty public constructor 
} 


@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    return inflater.inflate(R.layout.fragment_master_profile, container, false); 
    autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView); 
    String[] words = getResources().getStringArray(R.array.auto_complete); 
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,words) 

} 

}

答えて

0
public class master_profile extends Fragment { 

    AutoCompleteTextView autoCompleteTextView; 

    public master_profile() { 
     // Required empty public constructor 
    } 


    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     // Inflate the layout for this fragment 
     View rootView = inflater.inflate(R.layout.fragment_master_profile, container, false); 
     autoCompleteTextView = (AutoCompleteTextView) rootView.findViewById(R.id.autoCompleteTextView); 
     String[] words = getResources().getStringArray(R.array.auto_complete); 
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, words); 

     return rootView; 

    } 
} 
+0

。 – Bry

+0

新しいエラーはコンストラクタを解決できませんArrayAdapter – Bry

+0

ArrayAdapter adapter = new ArrayAdapter (getActivity()、android.R.layout.simple_list_item_1、words);私は私の答えを編集します –

関連する問題