मेरे पास Activity
है जिसमें SimpleCursorAdapter
और एक बटन के आधार पर ListView
है। जब मैं बटन क्लिक करता हूं, तो मैं पंक्ति ऊंचाई को बड़ा करना चाहता हूं। मैं बटन OnClick
पर इस बात के लिए TextView
ऊंचाई का उपयोग करने का फैसला किया:कोड सूची में देखें पंक्ति ऊंचाई देखें
TextView tvRow = (TextView) findViewById(R.id.tvRow);
tvRow.setHeight(20);
लेकिन यह सूची के केवल प्रथम पंक्ति बदल जाता है।
मैं Adapter
के getView
विधि में ऊंचाई बदल सकते हैं:
TextView tvRow = (TextView) view.findViewById(R.id.tvRow);
tvRow.setHeight(20);
लेकिन यह है कि कार्यक्षमता की आवश्यकता नहीं है; मुझे इसे OnClick
बटन पर चाहिए।
मैं बटन को टैप करके ListView
पंक्ति ऊंचाई कैसे बदल सकता हूं? शायद एक चाल भी :) आपके समय के लिए धन्यवाद।
अद्यतन:
जब मैं SimpleCursorAdapter
सब कुछ में इस कोड को ठीक काम करता है, लेकिन विधि getView
में BaseAdapter
में डाल:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = lInflater.inflate(R.layout.itemF, parent, false);
}
...
final LayoutParams params = view.getLayoutParams();
if (params == null) {
view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, mRowHeight));
}else {
params.height = mRowHeight; }
return view;
प्रदर्शन पर सूची सिर्फ इस पर ध्यान नहीं देता और उसके पंक्ति चौड़ाई रहता है वही। गलत क्या है?
अद्यतन:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/cbBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/llRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5dp" >
<TextView
android:id="@+id/tvName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Наименование фирмы"
android:textAllCaps="true"
android:textSize="14dp" />
<TextView
android:id="@+id/tvAddr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Адрес фирмы"
android:textSize="10dp" />
</LinearLayout>
तो क्या आप बटन पर क्लिक करते समय सभी पंक्तियों को बड़ा करना चाहते हैं? – CaseyB
कोड का आपका दूसरा टुकड़ा आपके जैसा ही है, क्या यह एक टाइपो है? – Gix
हां, मैं चाहता हूं कि सभी पंक्तियां एक ही आकार हों - बड़ी या छोटी। – Foenix