Answer the question
In order to leave comments, you need to log in
Why is there a syntax error on the line context.startActivities(i)?
Good afternoon!
When compiling the code below, an error occurs:
incompatible types: Intent cannot be converted to Intent[]
Please help me solve this problem.
FILE PostAdapter.java
public class PostAdapter extends RecyclerView.Adapter<PostAdapter.ViewHolderData> {
private List<NewPost> arrayPost;
private Context context;
private OnItemClickCustom onItemClickCustom;
private DbManager dbManager;
public PostAdapter(List<NewPost> arrayPost, Context context,
OnItemClickCustom onItemClickCustom) {
this.arrayPost = arrayPost;
this.context = context;
this.onItemClickCustom = onItemClickCustom;
this.dbManager = dbManager;
}
...
...
}
public void setData(NewPost newPost)
{
...
...
// Обработчик нажатия кнопки Delete
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deleteDialog(newPost, getAdapterPosition());
}
});
// Обработчик нажатия кнопки Edit
editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(context, EditActivity.class);
i.putExtra(MyConstants.IMAGE_ID, newPost.getUid());
i.putExtra(MyConstants.TITLE, newPost.getTitle());
i.putExtra(MyConstants.PRICE, newPost.getPrice());
i.putExtra(MyConstants.TEL, newPost.getTel());
i.putExtra(MyConstants.CAT, newPost.getCat());
i.putExtra(MyConstants.EDID_STATE, true);
context.startActivities(i);
}
});
}
@Override
public void onClick(View v)
{
onItemClickCustom.onItemSrlected(getAdapterPosition());
}
}
...
...
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.messageboard">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoToolBar">
android:theme="@style/Theme.MessageBoard">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".EditActivity"/>
</application>
</manifest>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question