我有使用ImageView和TextView的网格视图,并在按名称相册时显示每个歌手的专辑打开新的活动与ListView显示每个声音为歌手具体我需要知识这是怎么做的? 我创建GridView机智ImageView和TextView但不知道其余请帮助我 这是All的代码 ImageAdapter.java
public class ImageAdapter extends BaseAdapter {
private Context mContext;
String [] nameListReads;
int[] imageId ;
int []linkses;
String [] nameSora;
private static LayoutInflater inflater = null;
//Constructor
public ImageAdapter(Context context,String[] nameListRead, int [] nameImages, int links[], String nameSora[]){
this.nameListReads = nameListRead;
this.mContext = context;
this.imageId = nameImages;
this.linkses = links;
this.nameSora = nameSora;
inflater = (LayoutInflater)mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return nameListReads.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
//Create a new ImageView for each item referenced by the Adapter
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
Holder holder = new Holder();
View rowView;
rowView = inflater.inflate(R.layout.custom_name_reader,null);
holder.tv = (TextView) rowView.findViewById(R.id.textViewShow);
holder.img = (ImageView) rowView.findViewById(R.id.imageView);
holder.tv.setText(nameListReads[position]);
holder.img.setImageResource(imageId[position]);
rowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(mContext,"YOu Clicked " + nameListReads[position] +"\n"+imageId[position],Toast.LENGTH_LONG).show();
//Send intent to SingleViewActivity
// Intent i = new Intent(mContext,TestShowFullImage.class);
// i.putExtra("id",position);
// mContext.startActivity(i);
//__________________
Intent i = new Intent(mContext,ListSoundReader.class);
i.putExtra("id",position);
i.putExtra("name",nameSora[position]);
mContext.startActivity(i);
}
});
return rowView;
}
public class Holder{
TextView tv;
ImageView img;
}
}
FragmentGridView.java
public class FragmentGridView extends Fragment {
private GridView gridViewImage;
// ArrayList<Parts> parts = new ArrayList<>();
ImageAdapter imageAdapter;
public static String [] nameReaderList = {"محمدصديق المنشاوي","عبدالباسط عبدالصمد","الحصري","ماهر المعيقلي","المغامسي"};
//Keep all Images in array
public static int[] mThumbIds = {R.drawable.elmenshawy, R.drawable.abdelbaset, R.drawable.alhosary, R.drawable.almaqely,
R.drawable.almgamsy };
public static int [] links ={R.array.linkes, R.array.linkesElmenshawy, R.array.linkesElmenshawy, R.array.linkesElmenshawy, R.array.linkesElmenshawy};
public static String [] nameSora = {String.valueOf(R.array.name_allSwar), String.valueOf(R.array.name_allSwar), String.valueOf(R.array.name_allSwar), String.valueOf(R.array.name_allSwar)
, String.valueOf(R.array.name_allSwar)};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
// return inflater.inflate(R.layout.fragment_list_parts, container, false);
View rootView = inflater.inflate(R.layout.fragment_grid_view, null);
getAllWidgets(rootView);
setAdapter();
return rootView;
}
private void getAllWidgets(View view) {
gridViewImage = (GridView) view.findViewById(R.id.gridView);
}
private void setAdapter() {
imageAdapter = new ImageAdapter(getActivity(),nameReaderList,mThumbIds,links,nameSora);
gridViewImage.setAdapter(imageAdapter);
}
}
ListSoundReader.java
public class ListSoundReader extends AppCompatActivity{
private RecyclerView recycleViewSound;
ArrayList<Parts> dataArrayList = new ArrayList<>();
RecycleViewAdaptor recycleViewAdaptor;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_list_sound);
Intent ii = getIntent();
int position = ii.getExtras().getInt("id");
recycleViewSound = (RecyclerView)findViewById(R.id.recycleViewSound);
//Fetch the data in String.xml file
// String []ArrayKoran=getResources().getStringArray(R.array.name_allSwar);
String ArrayKoran=FragmentGridView.nameSora[position];
String []ArrayLink=getResources().getStringArray(R.array.linkes);
// String []ArrayLink=getIntent().getExtras().getStringArray(String.valueOf(FragmentGridView.links));
dataArrayList.clear();
for (int i = 0; i < ArrayKoran.length(); i++) {
Parts data = new Parts(ArrayLink[i], ArrayLink[i]);
dataArrayList.add(data);
}
recycleViewSound.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
recycleViewAdaptor = new RecycleViewAdaptor(getApplicationContext(), dataArrayList);
recycleViewSound.setAdapter(recycleViewAdaptor);
}
public class ListSoundReader extends AppCompatActivity{
private RecyclerView recycleViewSound;
ArrayList<Parts> dataArrayList = new ArrayList<>();
RecycleViewAdaptor recycleViewAdaptor;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_list_sound);
Intent ii = getIntent();
int position = ii.getExtras().getInt("id");
recycleViewSound = (RecyclerView)findViewById(R.id.recycleViewSound);
//Fetch the data in String.xml file
// String []ArrayKoran=getResources().getStringArray(R.array.name_allSwar);
String ArrayKoran=FragmentGridView.nameSora[position];
String []ArrayLink=getResources().getStringArray(R.array.linkes);
// String []ArrayLink=getIntent().getExtras().getStringArray(String.valueOf(FragmentGridView.links));
dataArrayList.clear();
for (int i = 0; i < ArrayKoran.length(); i++) {
Parts data = new Parts(ArrayLink[i], ArrayLink[i]);
dataArrayList.add(data);
}
recycleViewSound.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
recycleViewAdaptor = new RecycleViewAdaptor(getApplicationContext(), dataArrayList);
recycleViewSound.setAdapter(recycleViewAdaptor);
}
}
}
How query links every Singer On the one hand ؟
答案 0 :(得分:0)
实现此目标的步骤