Q1. How to set listItem data in RecyclerView Android.
Q2. Is there a way to show a preview of a RecyclerView's contents in the Android Studio editor?
Answer :-
tools:listitem="@layout/list_item"
Answer:
type /**
before the method declaration and press Enter, the javadoc comment block will be generated automatically.
Dependencies:-
RecyclerView :-
dependencies {
implementation 'com.android.support:recyclerview-v7:28.0.0'
}
RxAndroid(reactivexJava) :-
RecyclerView :-
RecyclerView :-
public void filterSocialShare() { List<Intent> targetShareIntents = new ArrayList<Intent>(); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); PackageManager pm = this.getPackageManager(); List<ResolveInfo> resInfos = pm.queryIntentActivities(shareIntent, 0); if (!resInfos.isEmpty()) { System.out.println("Have package"); for (ResolveInfo resInfo : resInfos) { String packageName = resInfo.activityInfo.packageName; Log.i("Package Name", packageName); if (packageName.contains("com.twitter.android") || packageName.contains("com.facebook.katana") || packageName.contains("com.whatsapp") || packageName.contains("com.google.android.apps.plus") || packageName.contains("com.google.android.talk") || packageName.contains("com.slack") || packageName.contains("com.google.android.gm") || packageName.contains("com.facebook.orca") || packageName.contains("com.yahoo.mobile") || packageName.contains("com.skype.raider") || packageName.contains("com.android.mms")|| packageName.contains("com.linkedin.android") || packageName.contains("com.google.android.apps.messaging")) { Intent intent = new Intent(); intent.setComponent(new ComponentName(packageName, resInfo.activityInfo.name)); intent.putExtra("AppName", resInfo.loadLabel(pm).toString()); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, "https://website.com/"); intent.putExtra(Intent.EXTRA_SUBJECT, "Share the content..."); intent.setPackage(packageName); targetShareIntents.add(intent); } } if (!targetShareIntents.isEmpty()) { Collections.sort(targetShareIntents, new Comparator<Intent>() { @Override public int compare(Intent o1, Intent o2) { return o1.getStringExtra("AppName").compareTo(o2.getStringExtra("AppName")); } }); Intent chooserIntent = Intent.createChooser(targetShareIntents.remove(0), "Select app to share"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetShareIntents.toArray(new Parcelable[]{})); startActivityForResult(chooserIntent,1); } else { Toast.makeText(getApplicationContext(), "No app to share.", Toast.LENGTH_LONG).show(); } } }// color code to add transparency in color in android100% — FF95% — F290% — E685% — D980% — CC75% — BF70% — B365% — A660% — 9955% — 8C50% — 8045% — 7340% — 6635% — 5930% — 4D25% — 4020% — 3315% — 2610% — 1A5% — 0D0% — 00
No comments:
Post a Comment