我的应用程序有列表视图,每个项目都有微笑代码,例如" Hello World :) its smiley Day :D "
我想用我的应用程序中的现有图像替换:)
和替换,:D
但图像在 SD 文件夹中没有绘制 ID,我可以这样做吗?如果是这样,如何或从哪里开始!
我试过用谷歌搜索它我找不到解决我问题的好方法
这是我的代码
@SuppressLint({ "ResourceAsColor", "NewApi" }) public View getView(final int position, View convertView, ViewGroup parent)
{
final ViewHolder holder;
final JSONObject p = (JSONObject) getItem(position);
if(convertView == null)
{
convertView = mInflater.inflate(R.layout.postbit, null);
holder = new ViewHolder();
convertView.setTag(holder);
holder.attach_handler = ( LinearLayout ) convertView.findViewById(R.id.attach_handler);
holder.attachments_box = ( LinearLayout ) convertView.findViewById(R.id.attachments_box);
holder.postbit_useravatar = ( ImageView ) convertView.findViewById(R.id.postbit_useravatar);
holder.postbit_username = ( TextView ) convertView.findViewById(R.id.postbit_username);
holder.postbit_timestamp = ( TextView ) convertView.findViewById(R.id.postbit_timestamp);
holder.postbit_boxmenu = ( ImageView ) convertView.findViewById(R.id.postbit_boxmenu);
holder.postbit_threadtitle = ( TextView ) convertView.findViewById(R.id.postbit_threadtitle);
holder.postbit_message = ( TextView ) convertView.findViewById(R.id.postbit_message);
holder.show_deletedicon = ( ImageView ) convertView.findViewById(R.id.show_deletedicon);
holder.show_quotedicon = ( ImageView ) convertView.findViewById(R.id.show_quotedicon);
//Set Fonts
holder.postbit_username.setTypeface(Api.font_short);
holder.postbit_timestamp.setTypeface(Api.font_text);
holder.postbit_threadtitle.setTypeface(Api.font_title);
holder.postbit_message.setTypeface(Api.font_text);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
/*********************************
* Add Values
*/
String deletedby = context.getResources().getString(R.string.post_deleted_byreason);
try {
deletedby = deletedby.replace("{1}", p.getString("del_username"));
deletedby = deletedby.replace("{2}", p.getString("del_reason"));
} catch (JSONException e) {
deletedby = context.getResources().getString(R.string.deleted_post);
e.printStackTrace();
}
String PostMessage = p.getString("pagetext");
//if deleted
if( p.getInt("visible") == 2 )
{
holder.show_deletedicon.setVisibility(View.VISIBLE);
}
try {
//IF deleted and aim not Admin
if ( p.getInt("show_delete") == 0 && p.getInt("visible") == 2 )
{
holder.attach_handler.setVisibility(View.GONE);
PostMessage = deletedby;
}else
if( p.getInt("visible") == 2 )
{
PostMessage = PostMessage+" \n\n"+deletedby;
}
} catch (JSONException e) {
e.printStackTrace();
}
holder.postbit_username.setText(p.getString("username"));
holder.postbit_threadtitle.setText(ShowThread.threadTitle);
holder.postbit_message.setAutoLinkMask(Linkify.ALL);
//here the Html Code
holder.postbit_message.setText(Html.fromHtml(PostMessage));