2017-05-16 14 views
0

을 해결할 수없는, 나는 그것이 내가 내 활동에 플로팅 작업을 가져올 수있는 내 빌드 Gradle을 함께 할 수있는 뭔가가하지만 이런 생각 : enter image description here플로팅 작업이 방법은 내가 플로팅 작업의 작업을 넣어 시도하는 문제가 발생하고

내 Gradle을은 :

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.example.afcosta.inesctec.pt.android" 
     minSdkVersion 21 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.0.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.android.volley:volley:1.0.0' 
    compile 'com.android.support:design:25.0.1' 
    testCompile 'junit:junit:4.12' 
} 

은 내가 디자인의 컴파일 버전을 변경하려하지만 난 너무 appcombat을 변경해야하고이 나에게 어떤 도움을 약간의 오차가 있습니다?

+1

'Register.this' 대신'view'를 전달해야합니다. – Piyush

+0

은 내보기를 전달합니까? 방법? –

+0

보기의 ID입니다 (내용). – Piyush

답변

0
build.gradle 

    dependencies 
    { 
     compile 'com.android.support:appcompat-v7:23.0.1' 
      compile 'com.android.support:design:23.0.1' 
    } 


     Snackbar snackbar = Snackbar 
        .make(coordinatorLayout, "Message is deleted", Snackbar.LENGTH_LONG) 
        .setAction("UNDO", new View.OnClickListener() { 
         @Override 
         public void onClick(View view) { 
          Snackbar snackbar1 = Snackbar.make(coordinatorLayout, "Message is restored!", Snackbar.LENGTH_SHORT); 
          snackbar1.show(); 
         } 
        }); 


     snackbar.show(); 
0

활동의 상위 레이아웃을보기로 전달할 수 있습니다.

Snackbar.make(View view, CharSequence text, int duration) 

Register.this는 플로팅 작업의 경우에는 작동하지 않습니다하지만 makeText 문맥을 필요로하기 때문에 토스트의 경우에 작동합니다. 이

Snackbar snackbar = Snackbar.make(Register.java,"ola",Snackbar.LENGTH_LONG); 

처럼

Toast.makeText(Context context, CharSequence text, int duration) 
+0

R.layout.activity_register이 오류가 발생합니다. : 메서드를 '확인할 수 없습니다 (int, java.lang.String, int) –

0

그냥 변경 ...

그것은 당신을 도울 것이

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

</LinearLayout 

처럼이

Snackbar snackbar = Snackbar.make(R.id.main,"ola",Snackbar.LENGTH_LONG); 

과 레이아웃 ID를 할당 교체

+0

넣어이 오류 : R.layout.activity_register 및이 오류 가져 오기 : 메서드를'확인할 수 없습니다 '(int, java.lang.String, int) –

+0

참조 내 업데이트 된 답변 및 일부 변경 –

0

) (내 친구

Snackbar snackbar = Snackbar 
    .make(coordinatorLayout, "Message is deleted", Snackbar.LENGTH_LONG) 
    .setAction("UNDO", new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      Snackbar snackbar1 = Snackbar.make(coordinatorLayout, "Message is restored!", Snackbar.LENGTH_SHORT); 
      snackbar1.show(); 
     } 
    }); 

snackbar.show을이 시도;