Ich möchte von API weitere Bilder in der horizontalen Bildlaufansicht zeigen und dynamisch Schaffung Objekt, wie:wie in horizontale Scroll-Ansicht Bilder von api laden android
0
A
Antwort
0
Sie recyclerview dafür verwenden können, nur versuchen, auf diese Weise
http://blog.nkdroidsolutions.com/android-horizontal-vertical-recyclerview-example/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/vertical_recycler_view"
android:background="#fff"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<View
android:background="#787878"
android:layout_width="match_parent"
android:layout_height="3dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/horizontal_recycler_view"
android:background="#fff"
android:layout_width="match_parent"
android:layout_height="70dp"/>
</LinearLayout>
HorizontalAdapter
public class HorizontalAdapter extends RecyclerView.Adapter<HorizontalAdapter.MyViewHolder> {
private List<String> horizontalList;
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView txtView;
public MyViewHolder(View view) {
super(view);
txtView = (TextView) view.findViewById(R.id.txtView);
}
}
public HorizontalAdapter(List<String> horizontalList) {
this.horizontalList = horizontalList;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.horizontal_item_view, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
holder.txtView.setText(horizontalList.get(position));
holder.txtView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,holder.txtView.getText().toString(),Toast.LENGTH_SHORT).show();
}
});
}
@Override
public int getItemCount() {
return horizontalList.size();
}
}
0
Verwenden horizontalscrollview wie folgt aus:
<HorizontalScrollView
android:id="@+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/addPhotoHeader"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp"
android:layout_toLeftOf="@+id/rightArrow"
android:layout_toRightOf="@+id/leftArrow">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/imageParent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
Verwendung von Java-Code wie dieser, wo pictureParent ein Linearlayout innerhalb HorizontalScrollView ist
final float scale = getResources().getDisplayMetrics().density;
int pixels = (int) (58 * scale + 0.5f);
ImageView image = new ImageView(this);
int leftPadding = (int) (10 * scale + 0.5f);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(pixels, pixels);
layoutParams.setMargins(0, 0, leftPadding, 0);
image.setLayoutParams(layoutParams);
// Adds the view to the layout
taskPictures.add(mFileTemp);
imagePlaceHolder.requestFocus();
Picasso.with(this).load(Crop.getOutput(result))
.skipMemoryCache()
.resize(92, 92)
.centerCrop().into(image);
pictureParent.addView(image);
Verwandte Themen
- 1. Bilder laden in Image in Android
- 2. Picasso Bilder laden langsam in Android, warum?
- 3. Kann nicht die unteren Elemente in der Android-Scrollansicht
- 4. Bilder mit Android Picasso in den Speicher laden/laden
- 5. Wie laden Bilder asynchron
- 6. Bilder nicht auf Android laden 5
- 7. Bilder laden
- 8. Wie hole ich Medien (Bilder) von der WordPress-Website mit JSON-API in Android?
- 9. Wie kann die horizontale Bildlaufleiste von Gridview in Android verwenden?
- 10. Lazy laden Bilder in UITableView
- 11. Horizontale Listenansicht untereinander android
- 12. Wie Bilder in Android zwischenspeichern?
- 13. Android horizontale Fortschrittsbalken?
- 14. Android - Wie Bilder in Recyclerview beim Scrollen
- 15. Android: Benutzerdefinierte horizontale Fortschrittsbalkenanimation
- 16. dynamisch laden Bilder in swipebox
- 17. css horizontale Mittel Bilder ohne Verwendung von% Prozent
- 18. Android horizontale Scrolling-Bildergalerie
- 19. Laden Sie Bilder in Codeigniter
- 20. versteckte CSS-Bilder laden
- 21. Android Horizontale RecyclerView scroll Richtung
- 22. Horizontale Ansichten innerhalb von Android GridLayout
- 23. Bilder gleichzeitig laden
- 24. UICollectionView - Horizontale Tabellenansicht - Swift - Anzeigen verschiedener Bilder in jeder Zeile
- 25. Wie horizontale Linie im Android programmatisch
- 26. Kann QWebView Bilder von Qt-Ressourcendateien laden?
- 27. Android Bild von URL in ListView laden
- 28. Android Liste der Bilder von MySQL-Datenbank
- 29. Android Kraft Horizontale (Landschaft) Layout
- 30. Picasso laden Bilder mit horizontalen Linien
Verwendung benutzerdefinierte Ansicht für diese – KrishnaJ
Verwendung RecyclerView mit horizontalem Layout –
https://examples.javacodegeeks.com/android/core/ui/horizontalscrollview/android-horizontalscrollview-example/ –