【发布时间】:2015-06-19 13:52:29
【问题描述】:
我在我的应用程序中添加了精美的封面流,它工作正常,但问题是,精美的封面流的视图显示很奇怪..
我按照这个例子https://github.com/davidschreiber/FancyCoverFlow
我想要这样的东西
但我得到的输出是这样的
我的意思是一次只有一张图片显示在屏幕上,在任何一侧我都看不到下一张图片
我的适配器
class CoverAdapter extends FancyCoverFlowAdapter {
private LayoutInflater inflater;
public Activity a;
View vi;
public ArrayList<HashMap<String, String>> arr;
public ArrayList<HashMap<String, String>> data;
public CoverAdapter(Activity homeActivity, ArrayList<HashMap<String, String>> myList) {
arr = myList;
a = homeActivity;
inflater = (LayoutInflater) a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return arr.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
System.out.println("position=" + position);
return position;
}
@Override
public View getCoverFlowItem(int position, View convertView, ViewGroup parent) {
Log.d("aaa", position + "");
View vi = convertView;
if (vi == null)
vi = inflater.inflate(R.layout.create_club_inflate, null);
TextView date1 = (TextView) vi.findViewById(R.id.txtDate1);
TextView date = (TextView) vi.findViewById(R.id.txtDate);
TextView team1_name = (TextView) vi.findViewById(R.id.txtTeamName);
TextView team2_name = (TextView) vi.findViewById(R.id.txtVanue);
TextView ground = (TextView) vi.findViewById(R.id.txt_time);
HashMap<String, String> product = new HashMap<String, String>();
product = arr.get(position);
System.out.println("name 1= " + product.get("str_team1_name") + " team 2="
+ product.get("str_team2_obj_name"));
date1.setText(product.get("str_srs"));
date.setText(product.get("str_startdt"));
team1_name.setText(product.get("str_team1_name"));
team1_name.setAlpha(5000);
team2_name.setText(product.get("str_team2_obj_name"));
team2_name.setAlpha(5000);
Typeface font = Typeface.createFromAsset(getAssets(), "TitilliumText22L006.otf");
int[] color = { Color.rgb(100, 100, 100), Color.rgb(255, 255, 255) };
float[] color_position = { 0, 1 };
TileMode tile_mode = TileMode.MIRROR; // or TileMode.REPEAT;
LinearGradient lin_grad = new LinearGradient(0, 0, 0, 50, color, color_position, tile_mode);
Shader shader_gradient = lin_grad;
team1_name.getPaint().setShader(shader_gradient);
team2_name.getPaint().setShader(shader_gradient);
team1_name.setTypeface(font);
team2_name.setTypeface(font);
ground.setText(product.get("str_grnd"));
product.get("str_sName");
product.get("str_team2_obj_sName");
String first_team_id = product.get("str__team1_id");
String second_team_id = product.get("str_team2_obj_id");
return vi;
}
【问题讨论】:
-
嗨 Roman 你有从哪里获得源代码的链接吗?
-
我会尽快回复@Roman
-
你需要mainactivity的代码吗?
-
嗨@Roman 你检查一个完整的例子有 ViewGroupExample 可能满足你的要求