package com.zilsesleri.FragmentPack; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.appcompat.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import com.zilsesleri.kornasiren.CustomAdapter; import com.zilsesleri.Utils.GetResources; import com.zilsesleri.kornasiren.MyConstants; import com.zilsesleri.kornasiren.R; /** * A simple {@link Fragment} subclass. */ public class FragmentB extends Fragment { private String[] soundName; private ListView listView; private int[] sound = new int[MyConstants.TOTAL_SOUND_B];/*Total sound number*/ public static String TAG_NAME_B = "b"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragmenta, container, false); listView = (ListView) view.findViewById(R.id.listview); /*set actionbar title*/ /*Set actionbar title*/ androidx.appcompat.app.ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); actionBar.setTitle(getResources().getString(R.string.str_Fragment_B)); //Activity for CustomAdapter /*adding sounds to int array*/ for (int i = 0; i < MyConstants.TOTAL_SOUND_B; i++) { String path = TAG_NAME_B + String.valueOf(i); int md_play = getResources().getIdentifier(path, "raw", getActivity().getPackageName()); sound[i] = md_play; } /*Customadapter defined.*/ CustomAdapter customAdapter = new CustomAdapter(getActivity(), GetResources.ArrayResourceB(getActivity(), soundName), sound, TAG_NAME_B); /*setting adapter to listview.*/ listView.setAdapter(customAdapter); return view; } }