我试图按照MVP标准开发一个项目。在我遵循的指南中,作者创建了单独的ViewHolder类。我尝试做同样的事情,但是适配器拒绝使用单独的ViewHolder。
有2个错误
无法解析符号' LessonCardView'
' onCreateViewHolder(ViewGroup,int)'在RVAdapter中与' onCreateViewHolder(ViewGroup,int)冲突' in' android.support.v7.widget.RecyclerView.Adapter&#39 ;;尝试使用不兼容的返回类型
RVAdapter.java
public class RVAdapter extends RecyclerView.Adapter<RVAdapter.LessonCardViewHolder> {
private String[] mDataset;
public RVAdapter(String[] dataset) {
mDataset = dataset;
}
@Override
public LessonCardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new LessonCardViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.lessons_item_card, parent, false));
}
@Override
public void onBindViewHolder(LessonCardViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return mDataset.length;
}
}
LessonCardViewHolcer.java
public class LessonCardViewHolder extends RecyclerView.ViewHolder implements LessonCardView {
private final TextView lessonCardText;
public LessonCardViewHolder(View itemView) {
super(itemView);
lessonCardText = (TextView) itemView.findViewById(R.id.lesson_card_view);
}
@Override
public void setLessonCardText(String text) {
lessonCardText.setText(text);
}
}
我创建了从RVAdapter中的LessonCardView继承的子类ViewHolder。错误消失了。但我不确定这是否正确。如果它适用于其他人,那么我做错了。
答案 0 :(得分:0)
从此
更改适配器声明ansible-playbook -e "runID=seq198837" provision.yml
ansible-playbook -e "runID=seq198837" build.yml
ansible-playbook -e "runID=seq198837" deploy.yml
到这个
Imports MySql.Data.MySqlClient
Public Class Login
Dim connection As New MySqlConnection("connstringhere")
' show/hide password text
Private Sub CheckBoxSP_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxSP.CheckedChanged
If PASSWORD.UseSystemPasswordChar = True Then
' show password
PASSWORD.UseSystemPasswordChar = False
Else
' hide password
PASSWORD.UseSystemPasswordChar = True
End If
End Sub
'button log in
Private Sub LOGINBUTTON_Click(sender As Object, e As EventArgs) Handles LOGINBUTTON.Click
Dim command As New MySqlCommand("SELECT `Id`, `password` FROM `users` WHERE `Id` = @username AND `password` = @password", connection)
command.Parameters.Add("@username", MySqlDbType.VarChar).Value = USERNAME.Text
command.Parameters.Add("@password", MySqlDbType.VarChar).Value = PASSWORD.Text
Dim adapter As New MySqlDataAdapter(command)
Dim table As New DataTable()
adapter.Fill(table)
If table.Rows.Count = 0 Then
MessageBox.Show("Invalid Username Or Password")
Else
MessageBox.Show("Logged In")
End If
End Sub
Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
答案 1 :(得分:0)
从您提供片段的方式来看,这些类在不同的文件中,或者没有正确嵌套在同一个文件中。
您是否尝试过使用AutoFilter()
而不是Sub Mail_small_Text_Outlook()
... your code
Dim xRg As Range
Dim xEmailAddr As String
Dim zEmailAddr As String
Set xRg = Sheet1.Range("C5:C11") ' include headers for autofilter to work
With xRg.Resize(, 3) 'include email addresses and recipient columns
.Sort key1:=.Cells(1, 3), key2:=.Cells(1, 2), header:=xlYes 'sort on recipients and email addresses to make sure you'll have adjacent filtered cells
xEmailAddr = GetEmailAddresses(.Cells, "MainR") 'get "Main Recipient" addresses
zEmailAddr = GetEmailAddresses(.Cells, "cc") 'get "cc" addresses
End With
...
rest of your code
End Sub
Function GetEmailAddresses(rng As Range, recipient As String) As String
With rng
.AutoFilter Field:=2, Criteria1:="*@*" ' filter referenced cells on 1st column with "0" content
.AutoFilter Field:=3, Criteria1:=recipient ' filter referenced cells on 2nd column with "4000" content
Select Case Application.WorksheetFunction.Subtotal(103, .Columns(3))
Case 2
GetEmailAddresses = .Offset(1, 1).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible).value
Case Is > 2
GetEmailAddresses = Join(Application.Transpose(.Offset(1, 1).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible).value), ";")
End Select
.Parent.AutoFilterMode = False
End With
End Function
?
答案 2 :(得分:0)
LessonCardViewHolder应该是RVAdapter中的嵌套类
答案 3 :(得分:0)
这是完整的解决方案 - Recyclerview Adapter类示例
public class IAdapter extends RecyclerView.Adapter<IAdapter.ViewHolder> {
Context context;
ArrayList<Model> modelList;
public ImagesAdapter(Context context,ArrayList<Model> modelList) {
this.context=context;
this.modelList=modelList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_items, parent, false);
return new ViewHolderImages(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Model model=photo.get(position);
userViewHolder.textView.setText(model.getTitle());
}
public class ViewHolder extends RecyclerView.ViewHolder{
TextView textView;
public ViewHolderImages(View itemView) {
super(itemView);
textView=(TextView)itemView.findViewById(R.id.textView);
}
}
@Override
public int getItemCount() {
return modelList.size();
}
}