我正在尝试使用我的应用程序中为材料设计更新的最新appcompat,以显示Lollipop中显示的切换视图(http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design -for-pre.html),问题是交换机没有显示出来.我的SDKmin是14,最大值是21.我在布局中使用以下代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/fragment_scheduler"
tools:context="com.stackoverflow.ranjith.androidprojdel.SchedulerUI">
<android.support.v7.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="switch"
app:showText="false" />
<Button
android:layout_width="match_parent"
android:text="start"
android:id="@+id/start"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
的build.gradle:
dependencies {
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:support-v4:+'
compile "com.android.support:appcompat-v7:21.0.+"
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud) 我想在我的布局中添加NavigationView,如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<android.support.design.widget.NavigationView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但问题是我在编译过程中遇到错误,如下所示:
C:\Users\IBM_ADMIN\Documents\Androidprojects\supporttest\app\src\main\res\layout\activity_main.xml
Error:(22) No resource identifier found for attribute 'menu' in package 'ranjithnair02.com.supporttest'
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\IBM_ADMIN\Documents\android-studio\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Run Code Online (Sandbox Code Playgroud)
我在menu/drawer.xml中添加了菜单项.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<group android:checkableBehavior="single">
<item
android:id="@+id/navigation_item_1"
android:checked="true"
android:icon="@drawable/abc_tab_indicator_mtrl_alpha"
android:title="First" />
<item
android:id="@+id/navigation_item_2" …Run Code Online (Sandbox Code Playgroud) android drawerlayout material-design navigationview androiddesignsupport
我正在尝试在Android应用程序中实现深层链接.
当我在Chrome浏览器等Android浏览器上点击自定义网址(xxxx:// repost?id = 12)的深层链接时,我的应用就会打开并运行良好.
问题是,在应用程序中,有一个webView小部件,我也想在那里进行深层链接工作.
目前,它显示Can't connect to the server错误.
提前致谢.
对于另一个活动中的另一个listView,项目的文本颜色是黑色的,就像它应该的那样.但是,在另一个活动中,当新项目创建时,在新线程中使用setAdapter时,如果我想要黑色,则文本颜色为白色.以下是Layout和Java代码的内容:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="project.yemeb.Search"
android:background="#ffffffff">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="@drawable/back_web"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:id="@+id/relativeLayout"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
android:id="@+id/button2"
android:background="#ffffffff"
android:onClick="onBtnClick"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignBottom="@+id/button2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#ffffffff"
android:layout_toLeftOf="@+id/button2"
android:layout_toStartOf="@+id/button2"
android:layout_alignTop="@+id/button2" />
</RelativeLayout>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:layout_alignParentBottom="true"
android:layout_below="@+id/relativeLayout"
android:headerDividersEnabled="false" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Java代码:
package project.yemeb;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个CollapsingToolbarLayout在它下面的列表视图,当列表视图滚动时,工具栏应该折叠,但滚动工具栏时它不工作不会崩溃.
使用本教程:http://android-developers.blogspot.in/2015_05_01_archive.html
注意:FrameLayout包含listview
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbara"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
framelayout代码:
<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"
tools:context="ranjithnair02.com.supporttest.BlankFragment">
<ListView
android:id="@+id/rcyv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:src="@android:drawable/ic_search_category_default"
app:borderWidth="0dp"
app:elevation="5dp"
app:rippleColor="@color/wallet_highlighted_text_holo_light" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android material-design android-toolbar androiddesignsupport android-collapsingtoolbarlayout
我正在尝试在cardview中创建一个应用程序,cardview包含两个需要彼此相邻放置的文本视图,但是文本视图正在重叠.有没有任何机制可以将相同的元素放在RelativeLayout(layout_below或layout_toRightOf)中,用于Cardview.我可以通过向Relativelayout添加阴影并使其看起来像Cardview来实现这一点,我想在Cardview中执行此操作.
我的布局代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/black"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:background="@color/white"
android:layout_width="200dp"
android:layout_height="200dp">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Textview one"
android:gravity="center"
android:textSize="36sp" />
<TextView
android:id="@+id/info_text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Textview two"
android:gravity="center"
android:textSize="36sp" />
</android.support.v7.widget.CardView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
目前显示如下附图:

android android-layout android-cardview android-5.0-lollipop
最近我更新了Android Studio和Android设计库,从那以后我得到了一个例外java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14.
不知道是什么问题,我几乎尝试了一切,它在棒棒糖5.1设备(nexus 4)中工作,但它在Android 4.4设备和4.02设备中不起作用.它在所有版本的更新之前工作.
我尝试了stackoverflow中提到的所有解决方案,但没有任何对我有用.
还尝试删除compile 'com.android.support:support-v4:22.2.0'build.gradle中的行但它也不起作用.
也尝试清洁和重建,再次它没有工作.
07-13 18:51:26.702: E/AndroidRuntime(1105): FATAL EXCEPTION: main
07-13 18:51:26.702: E/AndroidRuntime(1105): Process: com.stackoverflow.ranjith.androidprojdel, PID: 1105
07-13 18:51:26.702: E/AndroidRuntime(1105): java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:93)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:77)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:429)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
07-13 18:51:26.702: E/AndroidRuntime(1105): at com.stackoverflow.ranjith.androidprojdel.AppCompActivity.onCreate(AppCompActivity.java:34)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.app.Activity.performCreate(Activity.java:5231)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
07-13 18:51:26.702: E/AndroidRuntime(1105): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-13 18:51:26.702: E/AndroidRuntime(1105): …Run Code Online (Sandbox Code Playgroud) android android-appcompat appcompatactivity android-design-library androiddesignsupport
在我更新到Android设计支持22.2.1之前,我的项目工作正常,在我更新并运行程序后,我得到以下错误.该异常不会告诉代码中的哪一行或java文件导致错误,所以不知道要发布什么代码.这似乎是android设计支持的一些内部错误.
我的活动正在扩展AppCompatActivity,我的测试设备API 15(Android 4.04).
我使用NavigationView,并DrawerLayout在我的代码.
我的build.gradle
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.stackoverflow.ranjith.androidprojdel"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.+'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:cardview-v7:22.2.+'
compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.android.support:design:22.2.+'
compile 'joda-time:joda-time:2.8.1'
}
Run Code Online (Sandbox Code Playgroud)
例外:
07-19 00:52:49.338: E/AndroidRuntime(15556): FATAL EXCEPTION: main
07-19 00:52:49.338: E/AndroidRuntime(15556): java.lang.NullPointerException
07-19 00:52:49.338: E/AndroidRuntime(15556): at android.support.design.internal.NavigationMenuItemView.setIcon(NavigationMenuItemView.java:113)
07-19 00:52:49.338: E/AndroidRuntime(15556): at …Run Code Online (Sandbox Code Playgroud) android nullpointerexception android-appcompat androiddesignsupport
我有一个带有背景图像的画布。我需要知道是否有可能清除此画布上的涂料以重绘而不清除其背景图像。这是我的示例以及到目前为止的结果。
爪哇
public void setCanvas() {
if(mFile != null && mFile.exists()) {
mPictureBitmap = BitmapFactory.decodeFile(mFile.getAbsolutePath());
mBitmap = Bitmap.createScaledBitmap(mPictureBitmap, mImageView.getWidth(), mImageView.getHeight(), false);
mBitmap = mBitmap.copy(Bitmap.Config.ARGB_8888, true);
mCanvas = new Canvas(mBitmap);
mImageView.setImageBitmap(mBitmap);
mImageView.setOnTouchListener(this);
}
}
private void draw() {
mCanvas.drawColor(Color.TRANSPARENT, Mode.CLEAR); // THIS LINE CLEARS
int lastIndex = mCordHashMap.size() - 1;
int index = 0;
for (LinkedHashMap.Entry<String, ArrayList<Circle>> entry : mCordHashMap.entrySet()) {
ArrayList<Circle> coords = new ArrayList<Circle>();
coords = entry.getValue();
Path path = new Path();
String key = entry.getKey();
String surface = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用mediacontroller播放音频.我能够让音频工作但是当歌曲开始播放时我的mediacontroller上的播放按钮不会更新.如果按下mediacontroller上的播放按钮,它会暂停歌曲并寻找进度条.然后,如果我按暂停,它会再次播放该歌曲.我在打电话
mp.start()
Run Code Online (Sandbox Code Playgroud)
这不会更新播放按钮.当我打电话开始时,如何让按钮更改为暂停按钮?
public class QuickMusicPlayer implements MediaController.MediaPlayerControl {
private final MediaPlayer mMediaPlayer;
private final MediaController mMediaController;
private Activity mActivity;
public QuickMusicPlayer(View anchorView, Activity activity) {
mActivity = activity;
mMediaPlayer = new MediaPlayer();
mMediaController = new MediaController(activity);
mMediaController.setMediaPlayer(this);
mMediaController.setAnchorView(anchorView);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
}
public void setUrl(String url) {
mMediaPlayer.reset();
if (TextUtils.isEmpty(url)) {
ViewUtil.showCroutonAlert(mActivity, R.string.cant_play_music);
} else {
try {
mMediaPlayer.setDataSource(url);
mMediaPlayer.prepareAsync();
mMediaController.setEnabled(true);
mMediaController.show(0);
} catch (IOException e) {
e.printStackTrace();
} …Run Code Online (Sandbox Code Playgroud)