| |
---|
| | import android.view.LayoutInflater; |
---|
| | import android.view.View; |
---|
| | import android.view.ViewGroup; |
---|
| | import android.support.v4.app.Fragment; |
---|
| | import android.widget.AdapterView; |
---|
| | import android.widget.ArrayAdapter; |
---|
| | import android.widget.Button; |
---|
| | import android.widget.ListView; |
---|
| | import android.widget.Toast; |
---|
| | |
---|
| | |
---|
| | import org.ntlab.radishforandroidstudio.R; |
---|
| | import org.ntlab.radishforandroidstudio.cactusClient.Cactus; |
---|
| | import org.ntlab.radishforandroidstudio.cactusClient.models.Account; |
---|
| | |
---|
| | import java.util.ArrayList; |
---|
| | |
---|
| | public class CharactersFragment extends Fragment { |
---|
| | |
---|
| | @Override |
---|
| | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
---|
| | Bundle savedInstanceState) { |
---|
| | String test = getArguments().getString("test"); |
---|
| | Toast.makeText(getActivity(), test, Toast.LENGTH_SHORT).show(); |
---|
| | int position = getArguments().getInt("position"); |
---|
| | |
---|
| | Cactus c = (Cactus) getActivity().getApplication(); |
---|
| | Account account = c.getMyAccount(); |
---|
| | |
---|
| | // Inflate the layout for this fragment |
---|
| | return inflater.inflate(R.layout.characters_fragment, container, false); |
---|
| | } |
---|
| | |
---|
| | public void onStart() { |
---|
| | super.onStart(); |
---|
| | |
---|
| | @Override |
---|
| | public void onViewCreated(View view, Bundle savedInstanceState) { |
---|
| | |
---|
| | Button button = (Button) getActivity().findViewById(R.id.chooseInstances); |
---|
| | //↓↓↓↓↓↓↓↓画面遷移↓↓↓↓↓↓↓↓ |
---|
| | button.setOnClickListener(new View.OnClickListener() { |
---|
| |
---|
| | transaction.commit(); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | Button Nobita = (Button) getActivity().findViewById(R.id.NOBITA); |
---|
| | //↓↓↓↓↓↓↓↓画面遷移↓↓↓↓↓↓↓↓ |
---|
| | Nobita.setOnClickListener(new View.OnClickListener() { |
---|
| | |
---|
| | // ListViewに表示するデータ |
---|
| | final ArrayList<String> items = new ArrayList<>(); |
---|
| | items.add("キャラクター1"); |
---|
| | items.add("キャラクター2"); |
---|
| | items.add("キャラクター3"); |
---|
| | |
---|
| | // ListViewをセット |
---|
| | final ArrayAdapter adapter = new ArrayAdapter(this.getContext(), android.R.layout.simple_list_item_1, items); |
---|
| | ListView listView = (ListView) view.findViewById(R.id.list); |
---|
| | listView.setAdapter(adapter); |
---|
| | // セルを選択されたら詳細画面フラグメント呼び出す |
---|
| | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View v) { |
---|
| | //Toast.makeText(getActivity(), "hoge!", Toast.LENGTH_SHORT).show(); |
---|
| | public void onItemClick(AdapterView<?> parent, View v, int position, long id) { |
---|
| | |
---|
| | //ここでサーバーに何番のインスタンスが選ばれたのかを送信して、受け取った値に応じてキャラクターを送信しなければならない |
---|
| | //................................................... |
---|
| | //positionで選ばれたインスタンスわかるで!数字は0からやで!例えば1はデータ2やで!やで |
---|
| | FragmentManager manager = getFragmentManager(); |
---|
| | FragmentTransaction transaction = manager.beginTransaction(); |
---|
| | transaction.replace(R.id.fragment_place, new PlayerFragment()); |
---|
| | transaction.addToBackStack(null); |
---|
| | transaction.commit(); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | } |
---|
| | } |
---|
| | |
No description provided.
みんな頑張ろう
fc4a347
intomaster
fromキャラクターを選ぶ
on 20 Jul 2018