我正在关注{&3;}" T"但是当我运行应用程序时,我在logcat中收到以下消息。我不确定出了什么问题,因为班级应该在那里吗?
无法找到方法android.view.ViewAnimationUtils.createCircularReveal,从方法io.codetail.animation.ViewAnimationUtils.createCircularReveal
引用
MainActivity:
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.AdapterView;
import android.widget.Filter;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.curtrostudios.testapp.network.AppConfig;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.ArrayList;
import io.codetail.animation.SupportAnimator;
import io.codetail.animation.ViewAnimationUtils;
/**
* Created by CurTro Studios on 2/22/2016.
*/
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private ProgressDialog dialog=null ;
private String TAG="Main Activity";
private String tag_json_arry = "json_array_req";
private ProductsAdapter adapter;
private ListView list;
ArrayList<ProductRowData> rowdata;
private SearchView searchView;
private MenuItem myActionMenuItem;
LinearLayout mRevealView;
boolean hidden = true;
private ImageButton gallery_btn, photo_btn, video_btn, audio_btn, location_btn, contact_btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mRevealView = (LinearLayout) findViewById(R.id.reveal_items);
mRevealView.setVisibility(View.GONE);
gallery_btn = (ImageButton) findViewById(R.id.login_img_btn);
photo_btn = (ImageButton) findViewById(R.id.info_img_btn);
video_btn = (ImageButton) findViewById(R.id.share_img_btn);
audio_btn = (ImageButton) findViewById(R.id.sortAtoZ);
location_btn = (ImageButton) findViewById(R.id.sortDate);
contact_btn = (ImageButton) findViewById(R.id.sortRegion);
gallery_btn.setOnClickListener(this);
photo_btn.setOnClickListener(this);
video_btn.setOnClickListener(this);
audio_btn.setOnClickListener(this);
location_btn.setOnClickListener(this);
contact_btn.setOnClickListener(this);
list=(ListView)findViewById(R.id.productList);
list.setTextFilterEnabled(true);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Get item at position
ProductRowData item = (ProductRowData)parent.getItemAtPosition(position);
//Pass the image title and url to DetailsActivity
Intent intent = new Intent(MainActivity.this, ProductDetail.class);
intent.putExtra("sid", item.getSID());
intent.putExtra("name", item.getName());
intent.putExtra("image", item.getImageURL());
intent.putExtra("thumb", item.getThumbURL());
intent.putExtra("description", item.getDescription());
intent.putExtra("rating", item.getRating());
//Start details activity
startActivity(intent);
}
});
rowdata=new ArrayList<ProductRowData>();
dialog= new ProgressDialog(this);
dialog.setMessage("Loading...");
dialog.show();
JsonArrayRequest request = new JsonArrayRequest(AppConfig.URL_MAIN,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString()); try {
for(int i=0;i<response.length();i++){
String sid=response.getJSONObject(i).getString("sid");
String name=response.getJSONObject(i).getString("product_name");
String img;
String thumb = response.getJSONObject(i).getString("product_thumb");
String description = response.getJSONObject(i).getString("product_description");
String rating = response.getJSONObject(i).getString("product_rating");
img = response.getJSONObject(i).getString("product_pic");
rowdata.add(new ProductRowData(sid,name,img,thumb,description,rating));
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
adapter=new ProductsAdapter(MainActivity.this, rowdata);
list.setAdapter(adapter);
dialog.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Error: " + error.getMessage());
dialog.dismiss();
}
});
VolleyController.getInstance().addToRequestQueue(request, tag_json_arry);
}
@Override
public void onClick(View v) {
hidden = true;
switch (v.getId()) {
case R.id.login_img_btn:
break;
case R.id.info_img_btn:
break;
case R.id.share_img_btn:
break;
case R.id.sortAtoZ:
break;
case R.id.sortDate:
break;
case R.id.sortRegion:
break;
}
}
public void Info(){
Intent info = new Intent(MainActivity.this,
InfoActivity.class);
startActivity(info);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
myActionMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) myActionMenuItem.getActionView();
searchView.clearFocus();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Filter filter = adapter.getFilter();
if (TextUtils.isEmpty(newText)) {
filter.filter("");
} else {
filter.filter(newText);
}
return true;
}
});
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_info:
int cx = (mRevealView.getLeft() + mRevealView.getRight());
// int cy = (mRevealView.getTop() + mRevealView.getBottom())/2;
int cy = mRevealView.getTop();
int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
SupportAnimator animator =
ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(800);
SupportAnimator animator_reverse = animator.reverse();
if (hidden) {
mRevealView.setVisibility(View.VISIBLE);
animator.start();
hidden = false;
} else {
animator_reverse.addListener(new SupportAnimator.AnimatorListener() {
@Override
public void onAnimationStart() {
}
@Override
public void onAnimationEnd() {
mRevealView.setVisibility(View.INVISIBLE);
hidden = true;
}
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationRepeat() {
}
});
animator_reverse.start();
}
} else {
if (hidden) {
Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
mRevealView.setVisibility(View.VISIBLE);
anim.start();
hidden = false;
} else {
Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, radius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mRevealView.setVisibility(View.INVISIBLE);
hidden = true;
}
});
anim.start();
}
}
return true;
case android.R.id.home:
supportFinishAfterTransition();
return true;
case R.id.action_search:
return true;
case R.id.action_share:
return true;
}
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
//int id = item.getItemId();
//noinspection SimplifiableIfStatement
//if (id == R.id.action_search) {
// return true;
//}
//if (id == R.id.action_info) {
// return true;
//}
//if(id == R.id.action_share){
// //Share();
// return true;
//}
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
}
我的主要布局:
<android.support.design.widget.CoordinatorLayout
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"
android:fitsSystemWindows="true"
tools:context="com.curtrostudios.testapp.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<io.codetail.widget.RevealFrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reveal_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--row 1 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F0EFED"
android:orientation="horizontal"
android:padding="16dp">
<!--Gallery Icon -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:id="@+id/login_img_btn"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@mipmap/ic_login" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Login" />
</LinearLayout>
<!--Photo Icon -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:id="@+id/info_img_btn"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@mipmap/ic_info" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Info" />
</LinearLayout>
<!--Video Icon -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:id="@+id/share_img_btn"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@mipmap/ic_share" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Share" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F0EFED"
android:orientation="horizontal"
android:padding="16dp">
<!--Gallery Icon -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:id="@+id/sortAtoZ"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@mipmap/ic_a_z" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="A to Z" />
</LinearLayout>
<!--Photo Icon -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:id="@+id/sortDate"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@mipmap/ic_sort_date" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Date" />
</LinearLayout>
<!--Video Icon -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageButton
android:id="@+id/sortRegion"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="@mipmap/ic_region" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Region" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</io.codetail.widget.RevealFrameLayout>
</FrameLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
这是我的build.gradle(app)文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.myapp.testapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.wrapp.floatlabelededittext:library:0.0.6'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7@aar') {
transitive = true
}
compile ('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
transitive = true;
}
}
修改
这是在我的build.gradle(项目)文件中:
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
答案 0 :(得分:2)
对于其他任何可能看到这个与揭示动画/菜单的相同问题没有显示的人,这就是我解决问题的方法。 RevealFrameLayout并没有显示出来,它只是显示在其他一切之后。因此,正如您在下面的布局中所看到的,我只是将FrameLayout移到了所有其他内容之下,现在它完美无瑕。
主要布局
<android.support.design.widget.CoordinatorLayout
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"
android:fitsSystemWindows="true"
tools:context="com.myapp.testapp.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
//Issue was solved by adding the FrameLayout here.
//below all other content. Works perfectly now.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/reveal_layout" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
答案 1 :(得分:0)
检查导入的库。
在我的情况下,
void countBase(char *p)
{
int aCount = 0, cCount = 0, tCount = 0, gCount = 0;
char invalidBase[100];
int i, j=0;
while(*p != '\0')
{
if(*p == 'A' || *p == 'a')
{
aCount++;
}
else if(*p == 'C' || *p == 'c')
{
cCount++;
}
else if(*p == 'T' || *p == 't')
{
tCount++;
}
else if(*p == 'G' || *p == 'g')
{
gCount++;
}
else
{
invalidBase[j] = *p;
}
j++;
p++;
}
for(i = 0; invalidBase[i] != '\0'; i++)
{
printf("Invalid Base: %c\n", invalidBase[i]);
}
printf(" A: %i\n C: %i\n T: %i\n G: %i\n", aCount, cCount, tCount, gCount);
}
没有错误发生。
答案 2 :(得分:0)
正如图书馆明确提到你应该首先添加远程maven网址:
repositories {
maven {
url "https://jitpack.io"
}
}
然后是库依赖项:
compile ('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
transitive = true;
}
现在尝试构建项目并同步gradle!如果这没有帮助,请将aar版本更改为1.1.1
compile ('com.github.ozodrukh:CircularReveal:1.1.1@aar') {
transitive = true;
}
看看它是否有帮助。
如果问题仍然存在,我建议您阅读this博客!
答案 3 :(得分:0)
虽然,我无法弄清楚你为什么会收到错误,因为我没有尝试过该库,但我认为你可以轻松地实现循环显示而不使用上面的库。请查看Material-Animations,它有一个非常简洁的圆形显示工作示例,您可以轻松使用。
答案 4 :(得分:0)
让我猜一下,您正在测试前Lollipop设备/模拟器上的代码(并获得该错误)。
类别ViewAnimationUtils
已在Android 21 SDK(Lollipop)中引入。
您的minSdkVersion
是16
。看看this其他问题,建议支持库将圆形揭示动画带回Android 2.3。该库是CircularReveal。您必须分叉io.codetail.animation.ViewAnimationUtils
才能使用它。
从方法引用 io.codetail.animation.ViewAnimationUtils.createCircularReveal
编辑2:在看到更新的响应并且从OP知道logcat不是错误而只是警告
之后这根本不是问题。这是一个Dalvik
功能,它会检查缺少的类/方法,并在没有找到它们时发出警告。除非你真的试图调用它们,否则它不会崩溃。
OkHttp
库有类似警告,您可以看到they also say您可以忽略它们。
作为旁注,CircularReveal
库似乎use @TargetApi
注释应该使用@SuppressLint("NewApi")
。 @TargetApi
表示您应该仅从该Api级别调用该方法。无论如何,这不是警告的原因,因为此信息仅在编译时可用。