我试图使用Android设备监视器查看我的数据库表,它显示我错误的原因我不太确定.而且我没有运行DDMS的另一个实例.
它没有显示我的DDMS,而是向我展示了这个错误
[2015-09-10 17:39:53 - ddms] Could not open Selected VM debug port (8700). Make sure you do not have another instance of DDMS or of the eclipse plugin running. If it's being used by something else, choose a new port number in the preferences.
[2015-09-10 17:39:53 - ddms] Can't bind to local 8600 for debugger
[2015-09-10 17:39:53 - ddmlib] Broken pipe
java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:65)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:677) …
Run Code Online (Sandbox Code Playgroud) 我想在裁剪和重新调整位图大小后使用Glide将位图加载到ImageView.
我不想使用,ImageView.setImageBitmap(bitmap);
因为我正在加载大量图像,它可能会占用一些内存,虽然图像尺寸很小,我只需要使用Glide,因为我知道它可以优化图像缓存.
我读了这篇文章,但是当我尝试实现它时,我并不完全理解他的解决方案.所以也许某人有一个更清洁,更容易理解的解决方案.
这是我的代码,它拾取图像并从中创建一个位图.
我需要使用滑行代替ImageView.setImageBitmap(bitmap);
.
new AsyncTask<String, Void, Void>() {
Bitmap theBitmap = null;
Bitmap bm = null;
@Override
protected Void doInBackground(String... params) {
String TAG = "Error Message: ";
try {
//Load the image into bitmap
theBitmap = Glide.
with(mContext).
load("http://example.com/imageurl").
asBitmap().
into(-1, -1).
get();
//resizes the image to a smaller dimension out of the main image.
bm = Bitmap.createBitmap(theBitmap, 0, 0, 210, 80);
} catch (final ExecutionException e) {
Log.e(TAG, e.getMessage());
} …
Run Code Online (Sandbox Code Playgroud) 我试图利用Twitter登录我的小Android应用程序时遇到问题,它一直在提出错误,说Cannot find symbol 'Twitter'
我已经在网上搜索了几个解决方案,包括下面的这个,但没有找到任何可能的解决方案.
我已经清理,重建,甚至重新启动了我的Android工作室,试图重新同步Gradle但还没有解决方案.
这是我的Build.Gradle(Project)
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的Build.Gradle(应用程序)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' } …
Run Code Online (Sandbox Code Playgroud) 我试图使用小型大写字母制作我的ViewPager标签文本,但它不起作用,
我搜索并检查了与此相关的其他帖子,尝试了他们的解决方案,但仍然无法正常工作
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabTextAppearance">@style/MyCustomTextAppearance</item>
</style>
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
ViewPager选项卡布局
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
app:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MyCustomTabLayout" />
Run Code Online (Sandbox Code Playgroud)
请问任何确认的工作解决方案?
谢谢.
android android-layout android-viewpager android-studio android-tablayout
我有一个问题使"标题文本工具栏"在CollapsingToolbarLayout中向上滚动时不折叠.
我尝试了一些调整,使用app:layout_collapseMode ="none"作为我的android.support.v7.widget.Toolbar中的属性,但它不起作用.也许我的布局有问题.
以下是我想要实现的目标.
但是当我滚动到顶部时,工具栏也会折叠,并且tabBar也会向内滚动,并变得不可见.以下就是我现在所拥有的.
这是我的布局代码
<android.support.design.widget.CoordinatorLayout 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.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="250dp"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#20000000" />
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="none"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application Title"
android:textColor="#fff"
android:textSize="18sp" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.design.widget.TabLayout
android:id="@+id/detail_tabs"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_collapseMode="pin"
android:background="#00000000"
app:tabSelectedTextColor="#3498db"
app:tabTextColor="#000" />
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333" …
Run Code Online (Sandbox Code Playgroud) 我已经搜索但没有找到任何关于如何使用背景的浮动按钮的教程或库,如下面在Skype中使用的那样.
我使用这些有关制作浮动按钮的教程来学习本教程.
https://github.com/codepath/android_guides/wiki/Floating-Action-Buttons,https://www.bignerdranch.com/blog/floating-action-buttons-in-android-l/,https://开头的github .COM /代码路径/ android_guides /维基/设计,支持库
编辑请阅读!
据@Simon说,我能够使用https://github.com/futuresimple/android-floating-action-button库来实现浮动按钮布局.但后来我因为无法在库函数内部设置相对布局背景色而陷入困境.
请参阅下面的浮动按钮的Java代码,我已经删除了其他按钮,让Skype看起来很像.
public class FloatButtonActivity extends Activity {
RelativeLayout brl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_float_button);
//final View actionB = findViewById(R.id.action_b);
ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
drawable.getPaint().setColor(getResources().getColor(R.color.white));
/* Button 3 */
final FloatingActionButton actionA = (FloatingActionButton) findViewById(R.id.action_a);
actionA.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(FloatButtonActivity.this, "Clicked on this button 3", Toast.LENGTH_LONG).show();
}
});
/* Button 2 */
final FloatingActionButton actionB = …
Run Code Online (Sandbox Code Playgroud) 如何使用实现具有匹配多个视图的ID的RecylerView的片段来定位Viewpager?
我有一个MainActivity,它有一个Viewpager.Viewpager有5个标签.在这5个选项卡中,我使用RecylerViews在每个选项卡中加载图像.
RecylerView XML在不同的片段中重复使用,因此当使用Espresso访问它时,它会让抱怨ID与多个视图匹配.
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)
我的RecylerView不加载任何文本,只加载图像,所以我甚至不能做withText("Text here")
.我也不能onData()
用于RecylerViews.
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
Activity activity = mActivityRule.getActivity();
@Test
public void ExampleMethod() {
// perform a swipe
onView(withId(R.id.viewpager)).perform(swipeLeft());
// try to click on one of the recycler view items.
// this crashes:
onView(withId(R.id.recycler_view))
.perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
}
}
Run Code Online (Sandbox Code Playgroud)
所以它崩溃并指出错误
android.support.test.espresso.AmbiguousViewMatcherException:'with id:com.example.app:id/recycler_view'匹配层次结构中的多个视图.问题视图在下方标有"****MATCHES****".
//列出不同的层次结构
View Hierarchy:
View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=720, height=1280,
has-focus=false, has-focusable=true, has-window-focus=true,
is-clickable=false, is-enabled=true, is-focused=false, …
Run Code Online (Sandbox Code Playgroud) android android-fragments android-espresso android-recyclerview
我试图按照这个指南添加设计支持库https://github.com/codepath/android_guides/wiki/Design-Support-Library,我遇到了问题.
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
}
Run Code Online (Sandbox Code Playgroud)
试图添加这个,它在构建时给了我很多XML错误.
Error:(24, 63) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_default_mtrl_alpha').
Error:(25, 93) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_default_mtrl_alpha').
Error:(26, 33) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_activated_mtrl_alpha').
Error:(20, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_dark').
Error:(21, 118) No resource found that matches the given name (at …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在sitepoint http://www.sitepoint.com/guzzle-php-http-client/上关注本教程,我按照这里的步骤安装了http://docs.guzzlephp.org/en/最新/ overview.html #instal和我正在尝试运行第一个简单的例子,但它给了我一个问题.我还检查了我的PHP版本要求(5.5):我的是5.6,那就好了.
我正在使用MAC,请参阅下面的代码.
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'vendor/autoload.php';
use Guzzle\Http\Client;
use Guzzle\Http\EntityBody;
use Guzzle\Http\Message\Request;
use Guzzle\Http\Message\Response;
$client = new Client("https://qrng.anu.edu.au");
$request = $client->get('/API/jsonI.php?length=10&type=uint8');
$response = $request->send();
echo $body = $response->getBody(true);
Run Code Online (Sandbox Code Playgroud)
拜托,我错过了什么?
所以我正在开发一个带有mvp模式的应用程序,我在使用Dagger2时遇到了问题
我为我的演示者创建了一个名为HelloPresenter的界面.
然后我为该接口创建了一个名为HelloPresenterImpl的实现
我的HelloPresenter
public interface HelloPresenter {
public void sayHello();
}
Run Code Online (Sandbox Code Playgroud)
我的HelloPresenterImpl
public class HelloPresenterImpl implements HelloPresenter {
StoryView storyView;
@Inject
public HelloPresenterImpl(StoryView storyView) {
this.storyView = storyView;
}
@Override
public void sayHello() {
Log.d(TAG, "hello there");
}
}
Run Code Online (Sandbox Code Playgroud)
我的组件
@UserScope
@Component(dependencies = NetComponent.class, modules = RetrofitModule.class)
public interface StoryComponent {
void inject(MainActivity activity);
void inject(HelloPresenter helloPresenter);
}
Run Code Online (Sandbox Code Playgroud)
我的模块
@Module
public class HelloModule {
@Provides
public HelloPresenter providesHelloPresenter(final HelloPresenterImpl presenter){
return presenter;
}
}
Run Code Online (Sandbox Code Playgroud)
我的BaseApplication
public class BaseApplication extends …
Run Code Online (Sandbox Code Playgroud) android ×9
java ×2
android-collapsingtoolbarlayout ×1
bitmap ×1
build.gradle ×1
dagger-2 ×1
ddms ×1
guzzle ×1
php ×1
twitter ×1