我正在尝试在应用中实现类似的功能,这里是回收 View 中 Viewholder 的 fragment 。
回收商定制适配器
public class PostAdapterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView title,user,description,tag,time,designation;
Long date;
ImageView imageView,bookmark,profilepic,sharebutton,like;
RelativeLayout head;
LinearLayout content;
DatabaseReference reference;
Context context;
String name;
public void setContext(Context context) {
this.context = context;
}
public PostAdapterViewHolder (final View itemView) {
super(itemView);
itemView.setOnClickListener(this);
head = (RelativeLayout) itemView.findViewById(R.id.head);
content = (LinearLayout) itemView.findViewById(R.id.content);
imageView =(ImageView)itemView.findViewById(R.id.imageview);
designation = (TextView) itemView.findViewById(R.id.designation);
like =(ImageView)itemView.findViewById(R.id.like);
profilepic = (ImageView) itemView.findViewById(R.id.imageView2);
bookmark =(ImageView)itemView.findViewById(R.id.bookmark);
title = (TextView) itemView.findViewById(R.id.title);
description = (TextView) itemView.findViewById(R.id.description);
time = (TextView) itemView.findViewById(R.id.date);
tag = (TextView) itemView.findViewById(R.id.tag);
sharebutton = (ImageView) itemView.findViewById(R.id.sharebutton);
user = (TextView) itemView.findViewById(R.id.username);
like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ImageView i = (ImageView) itemView.findViewById(R.id.like);
Drawable a = i.getBackground();
if (a.getConstantState().equals(context.getDrawable(R.drawable.emptyup).getConstantState())){
i.setImageDrawable(context.getDrawable(R.drawable.fillup));
} else {
i.setImageDrawable(context.getDrawable(R.drawable.emptyup));
}
}
});
}
}
01-09 10:43:45.747 6602-6602/ctize.connectplus.com.communitize E/AndroidRuntime: FATAL EXCEPTION: main Process: ctize.connectplus.com.communitize, PID: 6602 android.content.res.Resources$NotFoundException: Resource ID #0x7f07007e at android.content.res.Resources.getValue(Resources.java:1397) at android.content.res.Resources.getDrawable(Resources.java:843) at android.content.Context.getDrawable(Context.java:458) at ctize.connectplus.com.communitize.PostAdapterViewHolder$2.onClick(PostAdapterViewHolder.java:98) at android.view.View.performClick(View.java:5226) at android.view.View$PerformClick.run(View.java:21350) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5582) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
最佳答案
您的应用在应显示相关 Activity 时崩溃了?
然后,如果是,将文件的显示从 Android 更改为位于文件层次结构最顶端的 Project:
从
到
并将drawable v-24目录下的drawable拖放到drawable目录下。
就是这样。试试看是否可以
编辑:我发现问题可能出现在 Android 6 API 23 但不是更高的 API
关于安卓.content.res.Resources$NotFoundException : Resource ID #0x7f07007e,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48161713/
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
电脑0x0000001A蓝屏错误怎么U盘重装系统教学分享。有用户电脑开机之后遇到了系统蓝屏的情况。系统蓝屏问题很多时候都是系统bug,只有通过重装系统来进行解决。那么蓝屏问题如何通过U盘重装新系统来解决呢?来看看以下的详细操作方法教学吧。 准备工作: 1、U盘一个(尽量使用8G以上的U盘)。 2、一台正常联网可使用的电脑。 3、ghost或ISO系统镜像文件(Win10系统下载_Win10专业版_windows10正式版下载-系统之家)。 4、在本页面下载U盘启动盘制作工具:系统之家U盘启动工具。 U盘启动盘制作步骤: 注意:制作期间,U盘会被格式化,因此U盘中的重要文件请注
我遇到了未定义方法`to_key'的问题这是我的books_controller.rbclassBooksController和我的索引页如下。index.html.erb......现在当我要访问索引页面时出现如下错误。undefinedmethod`to_key'for# 最佳答案 index通常返回一个集合。事实上,您的Controller符合要求。但是,您的View试图为其定义一个表单。正如您所发现的,这不会成功。表单适用于实体,而不适用于集合。该错误在您看来以及您希望如何处理index。
我如下询问了我的Rspec测试。Rspec-RuntimeError:Calledidfornil,whichwouldmistakenlybe4在相同的代码上(“items_controller.rb”的Rspec测试),我试图对“PUTupdate”进行测试。但是我收到错误消息“Paperclip::AdapterRegistry::NoHandlerError:找不到“#”的处理程序。我的Rspec测试如下。老实说,我猜这次失败的原因是“let(:valid_attributes)”上的“photo”=>File.new(Rails.root+'app/assets/images
我在rails中有一个API端点,默认情况下,如果您没有设置任何Content-Typeheader,则会处理中的参数application/x-www-form-urlencoded有没有办法在不指定header中的内容类型的情况下处理来自POST请求的rails中的json字符串? 最佳答案 在您的routes.rb文件中,您可以将POST路由放置在命名空间中,并像这样定义预期的格式:namespace:api,defaults:{format::json}dopost'example'=>'controller#action'
我正在构建一个Rails应用程序并且使用的是Rails4.0.1。我有一个错误,并注意到它在3个月前被称为rails上的一个错误,所以我决定:捆绑更新并获得rails4.0.3这样做之后,测试和服务器都不会启动,并且会抛出错误:gems/railties-4.0.3/lib/rails/railtie/configuration.rb:95:in`method_missing':undefinedmethod`action_mailer'for#(NoMethodError)目前我在config/environments/*中注释掉了action_mailer行,但最好能找到一个真正的
我有如下嵌套资源:resources:categoriesdoresources:productsend根据RailsGuides,Youcanalsouseurl_forwithasetofobjects,andRailswillautomaticallydeterminewhichrouteyouwant:Inthiscase,Railswillseethat@magazineisaMagazineand@adisanAdandwillthereforeusethemagazine_ad_pathhelper.Inhelperslikelink_to,youcanspecifyju
我想用RubyonRails进行身份验证,每个用户都有自己的帐户。但是现在我得到了这个错误:undefinedmethoduser_signed_in?for#有人能帮帮我吗?代码如下:完整跟踪:app/controllers/projects_controller.rb:69:in`require_login'activesupport(3.2.3)lib/active_support/callbacks.rb:418:in`_run__2505248868868045404__process_action__114470166732456289__callbacks'actives
require'net/http'require'rubygems'require'json'url=URI.parse('http://www.xyxx/abc/pqr')resp=Net::HTTP.get_response(url)#get_responsetakesanURIobjectdata=resp.bodyputsdata这是我在ruby中的代码,resp.data以xml形式提供给我数据。restapi默认返回xml数据,如果headercontent-type是application/json,则返回json。但我想要json格式的数据。为此我必须设置heade
我有这个可以为我生成一个超链接:我希望它显示在td标签中,所以我想使用这个content_tag来帮助我:"example")%>我想要我的td中的超链接,所以我有这样的东西:,:class=>"example")%>但是我收到语法错误,我该怎么办? 最佳答案 内联:'example')%>或block形式:'example')do%> 关于ruby-on-rails-如何在RoR中使用content_tag嵌入标签?,我们在StackOverflow上找到一个类似的问题: