है कोई भी कृपया मुझे बताएं कि एंड्रॉइड में डेटाग्रिड बनाने की कोई संभावना है, अगर हां मतलब है तो कृपया मुझे कुछ कोड स्निपेट्स में मदद करें, या कुछ संबंधित वेब यूआरएल दें।एंड्रॉइड में डेटाग्रिड डिस्प्ले कैसे बनाएं?
8
A
उत्तर
9
Book.java
package com.dgrid;
public class Book {
String title;
String author;
public Book(String title, String author) {
this.title = title;
this.author = author;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
>
<ListView
android:id="@+id/bookListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#ffffff"
/>
</AbsoluteLayout>
row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget0"
android:orientation="horizontal"
android:layout_toRightOf="@android:id/icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<com.dgrid.ListItemView
android:id="@+id/title"
android:layout_height="wrap_content"
android:layout_width="150px"
android:text="Title"
android:textSize="10sp"
android:textStyle="bold"
android:textColor="#ff000000"
/>
ListItemView.java
package com.dgrid;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.TextView;
public class ListItemView extends TextView {
private boolean isHeader = false;
private Paint linePaint;
public ListItemView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public ListItemView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ListItemView(Context context) {
super(context);
init();
}
public void init(){
linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
linePaint.setColor(Color.parseColor("#000000"));
}
public boolean isHeader() {
return isHeader;
}
public void setHeader(boolean isHeader) {
this.isHeader = isHeader;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if(isHeader){
canvas.drawColor(Color.parseColor("#AAFFFF99"));
}
canvas.drawLine(0, 0, getMeasuredWidth(), 0,linePaint);
canvas.drawLine(0, getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight(),linePaint);
canvas.drawLine(0,0, 0, getMeasuredHeight(),linePaint);
}
}
डेटाग्रिडएक्टिविटी.जावा
package com.dgrid;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class DatagridActivity extends Activity {
Context mContext;
Book[] books = {new Book("Title","Author"),new Book("Clean Code","Uncle Bob"),new Book("Face 2.0","Allen Cooper")};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.main);
ListView bookListView =(ListView)findViewById(R.id.bookListView);
LitemItemAdapter mcqListAdapter = new LitemItemAdapter(this,R.layout.row,books);
bookListView.setAdapter(mcqListAdapter);
}
class LitemItemAdapter extends ArrayAdapter<Book>{
public LitemItemAdapter(Context context, int textViewResourceId,
Book[] objects) {
super(context, textViewResourceId, objects);
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
Book item = books[position];
if (item != null) {
ListItemView titleView = (ListItemView) v.findViewById(R.id.title);
ListItemView authorView = (ListItemView) v.findViewById(R.id.author);
if(position == 0){
titleView.setHeader(true);
authorView.setHeader(true);
}
if(titleView != null){
titleView.setText(item.getTitle());
}
if(authorView != null){
authorView.setText(item.getAuthor());
}
}
return v;
}
}
}
+0
इस कोड को आजमाया नहीं है, लेकिन मुझे लगता है कि आप टेक्स्टव्यू को लपेटने के लिए विजेट 0 के बिना कर सकते हैं। 150px के लिए हार्डकोड शीर्षक भी है? क्या होता है यदि यह एक पंक्ति के लिए एक लंबा खिताब है, तो यह एक डाटाग्रिड की तरह नहीं दिखता है, नहीं? –
संबंधित मुद्दे
- 1. डेटाग्रिड पारदर्शी कैसे बनाएं?
- 2. डेटाग्रिड व्यू से डेटाटेबल कैसे बनाएं?
- 3. एएसपी.नेट एमवीसी 3 में कस्टम संपादक/डिस्प्ले टेम्पलेट्स कैसे बनाएं?
- 4. फ्लोट प्रेसिजन डिस्प्ले (एंड्रॉइड)
- 5. रीडोनली डेटाग्रिड में एक कॉलम संपादन योग्य कैसे बनाएं?
- 6. एंड्रॉइड में बीप कैसे बनाएं?
- 7. एंड्रॉइड में टेक्स्टएरिया कैसे बनाएं
- 8. एंड्रॉइड में फ़ाइल कैसे बनाएं?
- 9. डेटाग्रिड
- 10. क्लिक पर टूलटिप डिस्प्ले बनाएं और इसे
- 11. एचटीएमएल कैसे बनाएं। डिस्प्ले के लिए लाइन ब्रेक प्रदर्शित करें?
- 12. स्टैक ओवरफ़्लो जैसे विज़ुअल डिस्प्ले व्यू कैसे बनाएं?
- 13. स्क्रैच से एक तेज WPF डेटाग्रिड नियंत्रण कैसे बनाएं?
- 14. सी # कोड से डेटाग्रिड कॉलम खिंचाव कैसे बनाएं?
- 15. एंड्रॉइड में उलटी गिनती टाइमर कैसे बनाएं?
- 16. एंड्रॉइड में संपादन योग्य स्पिनर कैसे बनाएं?
- 17. एंड्रॉइड में लिंक बटन कैसे बनाएं
- 18. एंड्रॉइड एडिटटेक्स्ट में संकेत संकेत कैसे बनाएं?
- 19. एंड्रॉइड में ट्विटर शेयर बटन कैसे बनाएं?
- 20. एंड्रॉइड में यूट्यूब वीडियो थंबनेल कैसे बनाएं?
- 21. एंड्रॉइड में एक टक्कर ऐप कैसे बनाएं?
- 22. एंड्रॉइड में लाइव वॉलपेपर कैसे बनाएं?
- 23. एंड्रॉइड में पॉपअप विंडो कैसे बनाएं?
- 24. एंड्रॉइड में JSON प्रारूप डेटा कैसे बनाएं?
- 25. एंड्रॉइड में कस्टम वेबव्यू कैसे बनाएं?
- 26. एंड्रॉइड 4.0 में पूर्ण स्क्रीन कैसे बनाएं
- 27. एंड्रॉइड में पेड़ दृश्य कैसे बनाएं?
- 28. एंड्रॉइड में विस्तारणीय पैनल लेआउट कैसे बनाएं?
- 29. एंड्रॉइड में जावा थ्रेड डंप कैसे बनाएं?
- 30. एंड्रॉइड में बॉर्डरलेस बटन कैसे बनाएं
क्या आप डेटाग्रिड द्वारा अपना मतलब बता सकते हैं? – emmby
यह एक गिमे-तेह-कोडेज़ प्रश्न है, इसके बाद आपको पहले भुगतान करने के बाद कोड लिखने का प्रयास करें, और फिर यदि आपको समस्याएं हैं तो उन्हें यहां पूछें। – Reno
यहां एक एंड्रॉइड डेटाग्रिड घटक है: http://www.androidjetpack.com/Home/AndroidDataGrid – user2453876