让动漫中那些喜欢的人、喜欢的台词,让你难忘的话语,都保留在你的手机中吧
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/** * 创建DialogueFragment视图 * */ @TargetApi (Build.VERSION_CODES.HONEYCOMB) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View v = inflater.inflate(R.layout.fragment_acg_dialogue, container, false ); int id = (Integer) getArguments().getSerializable(EXTRA_ACG_ID); mAcg = AcgLab.get(getActivity()).getAcg(id); mDialogueTextView = (TextView) v.findViewById(R.id.dialogue_tv); // 从以下标点符号处换行 String dialogue = mAcg.getDialogue().replace( "," , "\n" ); dialogue = dialogue.replace( "。" , "\n" ); dialogue = dialogue.replace( "?" , "\n" ); dialogue = dialogue.replace( "!" , "\n" ); mDialogueTextView.setText(dialogue); mPersonageTextView = (TextView) v.findViewById(R.id.personage_tv); if (!mAcg.getPersonage().isEmpty()) { mPersonageTextView.setText( "--" + mAcg.getPersonage()); } else { mPersonageTextView.setText( "" ); } mHeadImageView = (ImageView) v.findViewById(R.id.avatar_iv); mRippleImageView = (ImageView) v.findViewById(R.id.ripple_iv); // 将该应用程序自带的句子和用户添加的句子分开处理 if (mAcg.getId() < AcgListFragment.SYSTEM_DIALODUE_LENGHT) { mHeadImageView.setImageResource(Integer.parseInt(mAcg.getHead())); mHeadImageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // 设置水波动画 Animation anim = AnimationUtils.loadAnimation( getActivity(), R.anim.anim_ripple); mRippleImageView.startAnimation(anim); AcgDialogueFragment.getPlayer().play(getActivity(), Integer.parseInt(mAcg.getSound())); } }); } else { // 图片路径不存在或者未设置 File file = new File(mAcg.getHead()); if (mAcg.getHead().isEmpty() || (!file.exists())) { // 设置默认图片 mHeadImageView.setImageResource(R.drawable.saber); } else { Bitmap bmp = PictureUtils.getScaledBitmapFromPath( getActivity(), mAcg.getHead()); bmp = PictureUtils.getRoundBitmap(bmp); mHeadImageView.setImageBitmap(bmp); } mHeadImageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // 设置水波动画 Animation anim = AnimationUtils.loadAnimation( getActivity(), R.anim.anim_ripple); mRippleImageView.startAnimation(anim); if (mAcg.getId() < AcgListFragment.SYSTEM_DIALODUE_LENGHT) { AcgDialogueFragment.getPlayer().play(getActivity(), Integer.parseInt(mAcg.getSound())); } else { if (mAcg.getSound().isEmpty()) { Toast.makeText(getActivity(), R.string.tip_not_sound, Toast.LENGTH_SHORT) .show(); } else { AcgDialogueFragment.getPlayer().play(getActivity(), mAcg.getSound()); } } } }); } return v; } |
演示图:
以上所述就是本文的全部内容了,希望能够对大家熟练掌握java开发app有所帮助。