下面是我用来显示使用gridview创建的网格的代码,它有图像,下面会出现图像文本。我想让一些文字闪烁,例如“image text3”和“image text5”使用户可以了解文本之间的区别,即闪烁和不闪烁的文本。任何人都可以帮助我。
GridView mGridMain1 = (GridView)findViewById(R.id.gvMain1);
Resources res = getResources();
List<AppInfo> listAppInfo = new ArrayList<AppInfo>();
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image1), "image text1"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image2), "image text2"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image3), "image text3"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image4), "image text4"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image5), "image text5"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image6), "image text6"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image7), "image text7"));
listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.image8), "image text8"));
mGridMain1.setAdapter(new AppInfoAdapter(this, listAppInfo));
mGridMain1.setOnItemClickListener(mItemClickListener);
答案 0 :(得分:0)
当然,Android支持开箱即用的闪烁标签!只需夸大使用它的布局就可以了。请参阅此提交:https://github.com/android/platform_frameworks_base/commit/9c1223a71397b565f38015c07cae57a5015a6500。
答案 1 :(得分:0)
我认为你只能通过创建一个 自定义适配器 类来实现tcTime = table_schedule.getColumns().get(0); //
tcTime.setCellValueFactory(new PropertyValueFactory("Time"));
tcTime.setText("string in your language you want column title to name");
的子项目(ChildViews
)上的动画。哪个项目为 动画(闪烁) 。
使用GridView
类创建自定义适配器。
BaseAdapter
在public class GridViewAdapterCustom extends BaseAdapter {
Context mContext;
List<AppInfo> listAppInfo;
public ListViewAdapterCustom(Context con,List<AppInfo> list){
mContext=con;
listAppInfo=list;
}
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
LayoutInflater inflater = (LayoutInflater)con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row; row = inflater.inflate(R.layout.listitemview, viewGroup, false);}
//Add this code to whichever textview you want to animate
TextView blinkable_text = (TextView)row.findViewById(R.id.textView);
Animation myFadeInAnimation;
Animation myFadeInAnimation = AnimationUtils.loadAnimation(null, R.anim.fade_in);
blinkable_text.startAnimation(myFadeInAnimation);
return row;
}
}
文件夹
fade_in.xml
个文件
anim
创建您自己的<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="50" android:repeatCount="infinite"/>
</set>
文件以初始化和设置文本字段