缩放列表视图 [英] Zoom the listview
问题描述
我有一个包含一个TextView一个ListView,我需要放大按钮点击这个TextView的,但我不能做到这一点,我什么都试过覆盖simplecursor适配器和覆盖getview()方法,但不能缩放在点击按钮的TextView,按钮列表视图外,我的code是:
I have a listview containing a textview and I need to zoom this textview on button click but I am not able to do it, I tried everything to override the simplecursor adapter and override the getview() method but couldn't zoom the textview on button click, the button is outside the listview and my code is:
这是ListView的布局:
this is the listview layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/bt_rating"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:button="@android:drawable/btn_star"
android:onClick="onclick"/>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/FontSizeInListView"
android:gravity="right"
/>
</LinearLayout>
修改
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder(){
Binds the Cursor column defined by the specified index to the specified view
public boolean setViewValue(View view, Cursor cursor, int columnIndex){
if(view.getId() == R.id.text1){
tv=(TextView)view;
}}**
这样一来我得到的TextView,但确保只有建立的最后一个将被渲染和缩放我 tv.settextsize(..)
但只有页面上创建最后的TextView会改变,因为我只有一个我这样怎么能得到所有的textviews并不仅仅是创建的最后一个?
so that way I get the textview but sure only the last one created will be rendered and in the zoom I do tv.settextsize(..)
but only the last textview created on page will change because I only have the id of that one so how can I get all the textviews and not just the last one created?
推荐答案
它的工作我做的是:
adapter =new SimpleCursorAdapter(this,R.layout.rating,cu,new String[]{"Title","Fav"}, new int[]{R.id.text1,R.id.bt_rating},CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
//added in last update
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder(){
/** Binds the Cursor column defined by the specified index to the specified view */
public boolean setViewValue(View view, Cursor cursor, int columnIndex){
if(view.getId() == R.id.text1){
tv=(TextView)view;
tv.setTextSize(SizeOfTextInListView);
}
});
而在变焦按钮:
//zoom in button click
final Button zoom_in_btn = (Button) findViewById(R.id.button_zoom_in);
zoom_in_btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(Zoom_counter<10){
SizeOfTextInListView= SizeOfTextInListView+Zoom_In_Out_value;
adapter.notifyDataSetChanged();
Zoom_counter++;
}
}
});
它完美地工作。
这篇关于缩放列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!