I'm trying to use Butter Knife in a custom adapter like the documentation advertises: http://jakewharton.github.io/butterknife/
I pasted the example code and inserted the layout with my RelativeLayout file:
#Override public View getView(int position, View view, ViewGroup parent) {
ViewHolder holder;
ButterKnife.setDebug(true);
if (view != null) {
holder = (ViewHolder) view.getTag();
} else {
view = inflater.inflate(R.layout.list_row_people, parent, false);
holder = new ViewHolder(view);
view.setTag(holder);
}
holder.name.setText("John Doe");
// etc...
return view;
}
This is the code of the ViewHolder (inline class of PeopleAdapter):
static class ViewHolder {
#BindView(R.id.name)
TextView name;
public ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
Unfortunately, holder.name.setText("John Doe"); throws a NullPointer exceptions as name is null. The debug output shows these lines:
13:11:32.816 11613-11613/com.myproject.debug D/ButterKnife: Looking up view binder for com.myproject.controller.adapters.PeopleAdapter$ViewHolder
13:11:32.827 11613-11613/com.myproject.debug D/ButterKnife: Not found. Trying superclass java.lang.Object
13:11:32.827 11613-11613/com.myproject.debug D/ButterKnife: MISS: Reached framework class. Abandoning search.
list_row_people.xml currently looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:padding="4dp"
android:text="#string/example_name"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
Reading https://github.com/JakeWharton/butterknife/issues/285, I added the following line to my proguard-rules.pro:
-keep class **$$ViewBinder { *; }
Edit:
Android Studio 2.1 with com.jakewharton:butterknife:8.0.1. This is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'kotlin-android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myproject"
minSdkVersion 18
targetSdkVersion 23
versionCode 18
versionName "0.0.16"
multiDexEnabled true
}
packagingOptions {
exclude 'main/AndroidManifest.xml'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
}
}
lintOptions {
abortOnError false
warning 'InvalidPackage'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
wearApp project(':wear')
testCompile 'junit:junit:4.12'
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
releaseCompile project(path: ':common', configuration: 'release')
debugCompile project(path: ':common', configuration: 'debug')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.jakewharton.timber:timber:2.5.0'
compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
compile 'com.squareup.picasso:picasso:2.5.2'
}
buildscript {
ext.kotlin_version = '1.0.1-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
In Butter Knife from Version 8.0.0.
The Runtime and compiler are now split into two artifacts.
compile 'com.jakewharton:butterknife:8.0.0'
apt 'com.jakewharton:butterknife-compiler:8.0.0'
Look at this Link also.
Related
I'm trying to bind view from adapter but it throws error
xml file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="accessHistoryItem"
type="com.example.api.model.response.AccessListItem" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="122dp"
android:layout_margin="30dp">
<View
android:id="#+id/borderLine"
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="#color/black"
app:borderLine="#{accessHistoryItem}"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="0dp"
android:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
binding adapter
#BindingAdapter("borderLine")
fun View.borderLine(item: AccessListItem?){
item.let {
}
exception
Cannot find a setter for <android.view.View app:borderLine> that accepts parameter type 'com.example.api.model.response.AccessListItem'
If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
Open File
gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example"
minSdkVersion 28
targetSdkVersion 30
versionCode 19
versionName "0.7.1"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
applicationVariants.all{
variant ->
variant.outputs.each{
output->
project.ext { appName = 'example' }
def formattedDate = new Date().format('dd-MM-yyyy')
// on below line we are creating a new name for our apk.
def newName = output.outputFile.name
newName = newName.replace("app-", "$project.ext.appName-v${variant.versionName}_${variant.versionCode}-$formattedDate-")
output.outputFileName = newName
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dataBinding{
enabled = true
}
}
dependencies {
implementation project(":api")
//rx
implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
//gson
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
//glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
api 'com.google.android.material:material:1.1.0-alpha06'
apply plugin: 'kotlin-kapt'
}
From your provided code snippets, there doesn't seem to be anything wrong with it. I suspect missing plugin in the app-level build gradle file. Add id 'kotlin-kapt' to the plugins.
I am trying to use AdblockWebView library to block ads on Android webview. I tried to connect with my phone but the developed app crashes. I am using the following code. Is there anything I should change.
MainActivit.java
import org.adblockplus.libadblockplus.android.webview.AdblockWebView;
public class MainActivity extends AppCompatActivity {
AdblockWebView superWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
superWebView = findViewById(R.id.main_webview);
superWebView.getSettings().setJavaScriptEnabled(true);
superWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
superWebView.getSettings().setDomStorageEnabled(true);
superWebView.setWebViewClient(new WebViewClient());
superWebView.clearCache(true);
superWebView.loadUrl("https://m.youtube.com/");
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<org.adblockplus.libadblockplus.android.webview.AdblockWebView
android:id="#+id/main_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.webview"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'org.adblockplus:adblock-android-webview:3.14'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Your issue is most likely coming from superWebView.clearCache(true);
Remove this line and the app should run.
I want to use pulseLayout In my Project but it's not working I made Demo Project for Find out Reason for it not able to conclude anything. I tried 2 pulse lib but none of them are working.
lib are : https://github.com/gaurav414u/android-ripple-pulse-animation
https://github.com/booncol/Pulsator4Droid
Layout File :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ripple="http://schemas.android.com/tools"
tools:context=".MainActivity">
<com.gauravbhola.ripplepulsebackground.RipplePulseLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:clipChildren="false"
ripple:rippleColor="#3D66C7"
ripple:rippleType="stroke"
ripple:strokeWidth="2dp"
ripple:startRadius="42dp"
android:layout_centerInParent="true"
ripple:endRadius="100dp"
ripple:duration="2000"
android:id="#+id/layout_ripplepulse">
</com.gauravbhola.ripplepulsebackground.RipplePulseLayout>
<pl.bclogic.pulsator4droid.library.PulsatorLayout
android:id="#+id/pulsator"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pulse_count="4"
app:pulse_duration="7000"
app:pulse_repeat="0"
android:layout_below="#+id/layout_ripplepulse"
app:pulse_color="#color/colorAccent"
app:pulse_startFromScratch="false"
app:pulse_interpolator="Linear">
</pl.bclogic.pulsator4droid.library.PulsatorLayout>
</RelativeLayout>
Activity :
public class MainActivity extends AppCompatActivity {
RipplePulseLayout layout_ripplepulse;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
layout_ripplepulse =findViewById(R.id.layout_ripplepulse);
layout_ripplepulse.startRippleAnimation();
}
}
App level Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.trueapps.wordsearchnewproject"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
implementation 'pl.bclogic:pulsator4droid:1.0.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.gauravbhola.ripplepulsebackground:library:1.0.0'
}
Project level Gradle :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In the Xml file header you are using
xmlns:ripple="http://schemas.android.com/tools"
Just replace it with
xmlns:ripple="http://schemas.android.com/apk/res-auto"
I am facing the very strange issue. When I am working with portrait mode data is not populating the RecyclerView but does in the Landscape mode.
But when I have tried it with emulator than it is working fine in both screen orientation.
Manifest file:
<activity android:name="user.com.hlthee.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
XML file:
<LinearLayout
android:orientation="vertical"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
app:cardElevation="24dp"
android:elevation="24dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/adherence_text"
android:textStyle="bold"
android:layout_margin="5dp"
android:textAlignment="center"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/primary_text"
android:text="Adherence"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_below="#+id/adherence_text"
android:id="#+id/action_with_adherence"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
THis is my java file:-
actionWithAdherence=(RecyclerView) findViewById(R.id.action_with_adherence);
actionWithAdherence.setLayoutManager(new GridAutofitLayoutManager(this,200));
ArrayList<Action> actionListWithAdherence=database.fetchDataFromAdherenceTable();
actionWithAdherence.setAdapter(new DashboardAdherence(this, actionListWithAdherence));
Solution Tried:
Adding of android:configChanges="keyboardHidden|orientation|screenSize"
but didn't help. I have also read from Internet that saving and restoring savedInstanceState might help. But I think this is only for saving the state ( i.e what was the state before moving to another activity.)
EDIT:-
Adaptor class:
public class DashboardAdherence extends RecyclerView.Adapter<DashboardAdherence.AdherenceHolder> {
List<Action> actionList;
Context context;
private View layoutInflater;
public DashboardAdherence(Context context, List<Action> actionList)
{
this.context=context;
this.actionList=actionList;
}
#Override
public int getItemCount() {
System.out.println("Size is "+actionList.size());
return 9;
}
#Override
public AdherenceHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.adherence_dashboard, viewGroup, false);
return new AdherenceHolder(view);
}
#Override
public void onBindViewHolder(AdherenceHolder adherenceHolder, int position) {
Action action=actionList.get(position);
adherenceHolder.actionName.setText(action.getAction_id());
adherenceHolder.actionAdherence.setValue(action.getUserPercentage());
adherenceHolder.actionAdherence.setText("55");
adherenceHolder.actionAdherence.setUnitVisible(true);
//circleProgressView[i].setBarColor(getResources().getColor(R.color.green));
}
public class AdherenceHolder extends RecyclerView.ViewHolder {
private CircleProgressView actionAdherence;
private TextView actionName;
public AdherenceHolder(View view)
{
super(view);
actionAdherence=(CircleProgressView) itemView.findViewById(R.id.action_adherence);
actionName=(TextView) itemView.findViewById(R.id.action_name);
}
}
}
MainActivity.java
public class MainActivity extends AppCompatActivity implements HealthVitalsFunction {
SharedPreferences app_preferences;
RecyclerView actionWithAdherence;
DbHelper database;
#Override
protected void onCreate(Bundle savedInstanceState) {
//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//set basic settings for app.
app_preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Constants.setTokenDB(app_preferences.getString("token", ""));
database = new DbHelper(MainActivity.this);
/*-------------------------------- Action with the Adherence------------------------*/
actionWithAdherence=(RecyclerView) findViewById(R.id.action_with_adherence);
//second parameter 3 represents it has 4 column
actionWithAdherence.setLayoutManager(new GridLayoutManager(this, 4));
//actionWithAdherence.setLayoutManager(new GridAutofitLayoutManager(this,200));
ArrayList<Action> actionListWithAdherence=database.fetchDataFromAdherenceTable();
actionWithAdherence.setAdapter(new DashboardAdherence(this, actionListWithAdherence));
}
#Override
protected void onResume() {
super.onResume();
}
#Override
public void onBackPressed() {
if (exit) {
finish();
} else {
Toast.makeText(this, "Press Back again to Exit.", Toast.LENGTH_SHORT).show();
exit = true;
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
exit = false;
}
}, 3000);
}
super.onBackPressed();
}
}
build.gradle(app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
/* splits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips'
universalApk false
}
}*/
defaultConfig {
applicationId "user.com.hlthee"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
/*release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}*/
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
res.srcDirs = ['src/main/res', 'src/main/assets/fonts']
}
}
dexOptions {
jumboMode true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
//for bottom bar
compile 'com.roughike:bottom-bar:2.0.2'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
//for splash screen
compile 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
//for volley
compile 'com.android.volley:volley:1.0.0'
/*compile 'com.mcxiaoke.volley:library-aar:1.0.0'*/
// compile 'com.nineoldandroids:library:2.4.0'
/*compile 'de.hdodenhof:circleimageview:2.1.0'*/
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.mikepenz:iconics-core:2.6.7#aar'
compile 'com.github.jjobes:SlideDateTimePicker:v1.0.4'
//graph library
compile 'com.github.lecho:hellocharts-android:v1.5.8'
compile('com.mikepenz:materialdrawer:5.3.6#aar') {
transitive = true
}
compile 'com.mikepenz:google-material-typeface:2.2.0.2.original#aar'
//Google Material Icons
compile 'com.mikepenz:fontawesome-typeface:4.6.0.2#aar'
/*compile 'com.jjoe64:graphview:4.2.0'*/
compile files('libs/commons-io-2.5.jar')
//compile files('libs/PDFRenderer-0.9.0.jar')
//To show the thumbnail of pdf
compile 'com.github.barteksc:pdfium-android:1.4.0'
//Comment this line before production
compile 'com.facebook.stetho:stetho:1.4.1'
//library for chart
compile 'com.github.lecho:hellocharts-android:v1.5.8'
//library for timelineView
compile 'com.github.alorma:timelineview:2.3.0'
//for constraint layout
//compile 'com.android.support.constraint:constraint-layout:1.0.0-beta1'
//for circular view
//compile 'com.mikhaellopez:circularimageview:3.0.2'
//for applozic chat api
compile project(':mobicomkitui')
compile 'com.google.android.gms:play-services-appindexing:9.0.2'
//for junit
testCompile 'junit:junit:4.12'
//for mockito(framework for making test writing process)
//testCompile 'org.mockito:mockito-core:1.10.19'
//for the curved image view . use in the goal
compile 'com.github.developer-shivam:crescento:1.0.0'
//for animated image views
compile 'com.flaviofaria:kenburnsview:1.0.7'
//universal image loader to load the image.
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
//for adherence progress circular bar
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.9.1'
//for the sectioned recycler view
compile 'com.github.IntruderShanky:Sectioned-RecyclerView:2.1.1'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.getkeepsafe.dexcount'
fetchDataFromAdherenceTable() method.
public ArrayList<Action> fetchDataFromAdherenceTable() {
SQLiteDatabase sqLiteDatabase=this.getReadableDatabase();
ArrayList<Action> actionList=new ArrayList<>();
Cursor cursor=sqLiteDatabase.rawQuery(" select * from "+adherenceActionCOlumnTableName, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()){
Action action=new Action();
action.setAction_id(cursor.getString(cursor.getColumnIndex(adherenceActionCOlumn_id)));
action.setUserPercentage(cursor.getInt(cursor.getColumnIndex(adherenceActionCOlumn_adherence)));
actionList.add(action);
cursor.moveToNext();
}
cursor.close();
return actionList;
}
Adapter xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_margin="#dimen/activity_horizontal_margin"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<at.grabner.circleprogress.CircleProgressView
app:cpv_maxValue="100"
app:cpv_textSize="15dp"
app:cpv_textColor="#color/white"
app:cpv_unit="%"
app:cpv_unitSize="10dp"
app:cpv_unitColor="#color/white"
app:cpv_unitScale="1"
app:cpv_rimColor="#color/secondary_background"
app:cpv_rimWidth="10dp"
app:cpv_barWidth="4dp"
android:id="#+id/action_adherence"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:id="#+id/action_name"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:layout_marginTop="5dp"
android:text="Exercise"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I dont know why I got this error message:
Process: *.*.*, PID: 24384
java.lang.NoSuchFieldError: No static field CoordinatorLayout_LayoutParams of type [I in class Landroid/support/design/R$styleable; or its superclasses (declaration of 'android.support.design.R$styleable' appears in /data/app/*.*.*-2/base.apk)
at android.support.design.widget.CoordinatorLayout$LayoutParams.<init>(CoordinatorLayout.java:2274)
at android.support.design.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:1439)
at android.support.design.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:92)
my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<ListView
android:id="#+id/listview_diary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="#null"
android:dividerHeight="16dp"
android:fadingEdge="none"
android:fitsSystemWindows="true"
android:padding="12dp"
android:scrollbars="none"
android:background="#android:color/white"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add_diary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:clickable="true"
android:padding="8dp"
android:src="#mipmap/ic_add"
app:backgroundTint="#color/colorPrimary"
app:borderWidth="0dp"/>
</android.support.design.widget.CoordinatorLayout>
my gradle :
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "*.*.*"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "2g"
incremental true
preDexLibraries = false
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://raw.github.com/felipecsl/m2repository/master' }
// maven { url "https://jitpack.io" }
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.github.florent37:materialviewpager:1.2.0#aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
...
just update the same version of the following plugin's
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:support-v4:24.0.0'
like this
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'