setContentView()的类型是什么

时间:2017-06-22 09:59:36

标签: android data-binding kotlin android-databinding setcontentview

请检查编辑。

setConentView()

我收到以下错误指向fun <T: ViewDataFinding!> setContentView(activity:Activity!, layoutId:Int):T!

类型接口失败:没有足够的信息来推断

中的参数T.
 Error:(21, 15) error: cannot find symbol class MainActivityBinding

请明确说明。

修改:

所以根据android documentation,它的返回类型将是MainActivityBinding。但是当我添加所需的更改时

val binding = DataBindingUtil.setContentView(this @ MainActivity,R.layout.activity_main)

我收到错误

{{1}}

2 个答案:

答案 0 :(得分:1)

你可以使用

.portfolio-items article img {
  width: 100%;
}

.portfolio-item {
  display: block;
  position: relative;
  -webkit-transition: all 0.2s ease-in-out;
  -moz-transition: all 0.2s ease-in-out;
  -o-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
}
.portfolio-item img {
  -webkit-transition: all 300ms linear;
  -moz-transition: all 300ms linear;
  -o-transition: all 300ms linear;
  -ms-transition: all 300ms linear;
  transition: all 300ms linear;
  background: #fff;
  opacity: 0.9;
}

.portfolio-item .portfolio-desc {
  display: block;
  opacity: 0;
  position: absolute;
  width: 100%;
  left: 0;
  top: 0;
  color: rgba(220, 220, 220, 0.7);
}
.portfolio-item:hover .portfolio-desc {
  padding-top: 20%;
  height: 100%;
  transition: all 200ms ease-in-out 0s;
  opacity: 1;
}

.portfolio-item .portfolio-desc a {
  color: #ED502E;
}
.portfolio-item .portfolio-desc a:hover {
  /*text-shadow: 2px 2px 1px rgba(0, 0, 0, 0.7);*/
  text-decoration: none;
}
.portfolio-item .portfolio-desc .folio-info {
  top: -20px;
  padding: 30px;
  height: 0;
  opacity: 0;
  position: relative;
}
.portfolio-item:hover .folio-info {
  height: 100%;
  opacity: 0.8;
  transition: all 500ms ease-in-out 0s;
  top: -10px;
}

.portfolio-item .portfolio-desc .folio-info h5 {
  text-transform: uppercase;
}
.portfolio-item .portfolio-desc .folio-info p {
  font-size: 12px;
}
.content-item {
  overflow: hidden;
  backface-visibility: hidden;
}
.overlay {
  border-bottom: 76px solid #000000;
  border-left: 360px solid #000000;
  bottom: 0;
  height: 0;
  opacity: .65;
  position: absolute;
  right: 0;
  text-indent: -9999px;
  transition: all .9s ease-out;
  width: 0;
}
.content-item:hover .overlay {
  border-bottom: 292px solid #000000;
  border-left: 360px solid #000000;
  transition: all .9s ease-out;
}
.corner-overlay-content {
  bottom: 26px;
  color: #ffffff;
  position: absolute;
  right: 114px;
  transition: all .5s ease-out;
  font-size: 40px;
}
.content-item:hover .corner-overlay-content {
  opacity: 0;
  transition: all .10s ease-out;
}
.overlay-content {
  bottom: 0;
  color: #333;
  left: 0;
  opacity: 0;
  padding: 30px;
  position: absolute;
  right: 0;
  top: 0;
  transition: all .10s ease-out;
}
.overlay-content p {
  color: #ffffff;
  position: absolute;
  right: 114px;
  font-size: 40px;
  bottom: 124px;
}

.content-item:hover .overlay-content {
  opacity: 1;
  transition: all .5s ease-out;
}

val binding: MainActivityBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)

答案 1 :(得分:-1)

android

中只有三个版本的setContentView
  • void setContentView(View view,ViewGroup.LayoutParams params)
  • void setContentView(View view)
  • void setContentView(int layoutResID)

您正在使用的setContentView版本未定义。