嗨,我正在开发iPhone应用程序,我试图为edittext设置一个边框.我是按照以下方式做到的:
int borderWidth = 1;
CALayer *leftBorder = [CALayer layer];
leftBorder.borderColor = [UIColor whiteColor].CGColor;
leftBorder.borderWidth = borderWidth;
leftBorder.frame = CGRectMake(0, textField.frame.size.height - borderWidth, textField
.frame.size.width, borderWidth);
[textField.layer addSublayer:leftBorder];
Run Code Online (Sandbox Code Playgroud)
我对IB中的edittext设置了一些约束,这样当我旋转设备时,它会根据它调整文本字段的宽度.我的问题是调整edittext的宽度而不是调整我为编辑文本设置的CALayer的宽度.所以我想我必须为我的CALayer项目设置一些约束.但我不知道该怎么做.有人知道吗?需要帮忙.谢谢.
我正在开发小型Android应用程序,其中我将drawable资源设置为线性布局的背景.现在,我想要做的是动态地改变线性布局的背景颜色,但是在可绘制资源中.我的代码看起来像:
// bcd.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:endColor="#22000000"
android:startColor="#22000000"
android:angle="270" />
<stroke
android:width="3dp"
android:color="@color/white" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)
<LinearLayout
android:id="@+id/lin_llt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
Run Code Online (Sandbox Code Playgroud)
我在我的活动中设置了线性布局的背景,如下所示......
parentLayout = (LinearLayout) view.findViewById(R.id.lin_llt);
parentLayout.setBackgroundResource(R.drawable.bcd);
Run Code Online (Sandbox Code Playgroud)
现在我想做什么我想改变我的可绘制资源的颜色,这意味着改变我的线性布局的颜色,圆角和填充定义在drawable ..
我按照以下方式尝试了这个
ShapeDrawable bgShape = (ShapeDrawable )parentLayout.getBackground();
bgShape.getPaint().setColor(Color.BLACK);
Run Code Online (Sandbox Code Playgroud)
但它不适合我.任何其他解决方案
那怎么办......需要帮助......谢谢......
嗨,我正在开发一个Android应用程序.在我的应用程序中,我正在使用Sherlock动作.我在动作栏中定义了几个菜单项,如下所示
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/card_menu"
android:actionLayout="@layout/action_button"
android:showAsAction="always"
android:title="cards">
<menu>
<item
android:id="@+id/C1"
android:title="C1"/>
<item
android:id="@+id/C2"
android:title="c2"/>
<item
android:id="@+id/C3"
android:title="C3"/>
</menu>
</item>
<item
android:id="@+id/notification"
android:actionLayout="@layout/notification_icon"
android:icon="@drawable/notification"
android:showAsAction="always"
android:title="Notifications"/>
<item
android:id="@+id/filter"
android:icon="@drawable/filter"
android:showAsAction="always"
android:title="Filter"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
和我的action_button看起来像:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/menu_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/spinner_ab_focused_maroon"/>
<TextView
android:id="@+id/menu_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageView0"
android:text="C1"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
现在一切都显示出来但我的问题是当我点击card_menu item
我定义子菜单的位置并定义动作布局时.它没有显示那些子菜单.我的其他菜单项工作正常.只有当我为包含子菜单的项目定义动作布局时,我才能显示子菜单.如果我删除动作布局,它工作正常.
我知道如果我们为item定义动作布局,那么我们必须手动处理click侦听器.我是按照以下方式做到的
final MenuItem item = menu.findItem(R.id.card_menu);
item.getActionView().setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onOptionsItemSelected(item);
Toast.makeText(getActivity(), "click on menu", Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud)
我能够处理该项目的单击事件,但无法显示下拉子菜单项. …
嗨,我正在开发我正在使用的Android应用程序我正在使用单个Activity
和3个片段.所以考虑我有3个片段AB C.当我从A切换到B时,我添加Fragment
到Backstack和simillar for B to C.现在当我从C点击它时,它显示B和类似的B到A也是如此.
但事情是,当我从C到B或B来到A时,它不会调用onResume()
或任何其他生命周期方法Fragment
.
我想要做的每件事Fragment
我都有不同的头衔ActionBar
.所以,在我的代码中,当我从A移动到B或B到c时,我正在更改片段内的活动标题.但是,当我点击它时它不会改变.
实际问题是什么?为什么从后台弹出后它没有呼唤onResume()
我Fragment
?我该如何解决这个问题?需要帮忙.谢谢.
嗨,我正在开发Android应用程序.在我的应用程序中,我正在使用操作栏.我想让中心在动作栏中对齐我的窗口标题.我知道可以使用xml文件.但我想用风格来做它,以便它适用于我的每个窗口,如何做到这一点需要帮助.谢谢.
嗨,我正在开发一个Iphone应用程序我想在服务器响应后设置cookie并将其用于另一个请求.我的网络请求看起来像.
NSURLSession *session = [NSURLSession sharedSession];
[[session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
NSLog(@"sttaus code %i", httpResp.statusCode);
if (error) {
[self.delegate signinWithError:error];
}
else {
[self.delegate signinWithJson:data];
}
}] resume];
Run Code Online (Sandbox Code Playgroud)
但我不知道如何设置cookie.我知道我必须使用,NSHTTPCookieStorage
但我不知道如何设置.而且我也希望将cookie用于其他请求.有没有人知道这件事?需要帮忙.谢谢.
看到我试过这种方式
NSURLSession *session = [NSURLSession sharedSession];
[[session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
if(error) {
[self.delegate signinWithError:error];
}
else {
NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
NSHTTPCookie *cookie;
NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary];
NSDictionary* headers = …
Run Code Online (Sandbox Code Playgroud) 嗨,我是IOS开发的新手.我知道如何在IOS应用程序中使用图像.但我不知道如何使用开发人员网站中提到的共享或书签图标等默认图像.我想用它们.我必须下载那些图像集或xcode中可用的图像?如果我们必须下载那些图像集,那么我可以在哪里获得这些图标.需要帮助谢谢.
我想从父活动中关闭子活动.我的流程就像活动A在活动AI打开活动B中打开.但同时我的活动A正在做一些后台任务.当我得到后台任务的结果时,我想关闭活动A中的活动B.
是否可以这样做.需要帮忙.谢谢.
嗨,我开发了一个Android库,现在我想混淆它进行重新分配.我使用eclipse和android版本4.1.2开发我的库.我试着用eclipse和pro-guard进行混淆.我做出口,也把proguard.config = proguard-project.text
在project-properties
,但它不产生任何jar文件.它显示了我不允许图书馆项目的结果.
所以我不知道如何混淆android库项目.我需要有关如何混淆android库项目的帮助.
需要帮助谢谢.
嗨,我正在开发小型Android应用程序,其中我想显示简单的gridview与一些元素.它工作正常.唯一的问题是,即使有空间,它总是只显示两列.它将屏幕划分为2列并仅显示两个元素.如果我将列数设置为数字,即不是auto_fit,则表示正确显示.我的代码看起来像:
<FrameLayout 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"
>
<GridView
android:id="@+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="5dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp">
</GridView>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我的网格元素看起来像:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.example.androidcardlayout.MainActivity" >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="100dp"
android:layout_height="150dp"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:id="@+id/cardMianRlt"
android:layout_width="100dp"
android:layout_height="150dp"
>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我做错了吗?需要一些帮助.谢谢.
android ×7
ios ×2
autolayout ×1
back-stack ×1
background ×1
calayer ×1
center-align ×1
drawable ×1
gridview ×1
icons ×1
ios7 ×1
menu ×1
nsurlsession ×1
obfuscation ×1
parent-child ×1
proguard ×1
submenu ×1
title ×1