可能重复:
关闭/隐藏Android软键盘
首先,我已经看到了这个帖子.我试过那里接受的方法..但没有什么对我有用..
我的应用程序中有两个屏幕.
在我的第一个屏幕中,我希望用户名EditText专注于启动,键盘应该是可见的 ..这是我的实现(通过删除不必要/不相关的代码简化)..
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dip"
android:paddingRight="20dip">
<EditText android:id="@+id/username"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:hint="Username"
android:imeOptions="actionDone" android:inputType="text"
android:maxLines="1"/>
<EditText android:id="@+id/password"
android:password="true"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Password" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
class AppLogin extends Activity{
private EditText mUserNameEdit = null;
private EditText mPasswordEdit = null;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.app_login);
mUserNameEdit = (EditText) findViewById(R.id.username);
mPasswordEdit = (EditText) findViewById(R.id.password);
/* code to show keyboard on startup.this code is not working.*/ …
Run Code Online (Sandbox Code Playgroud) 我在一个活动中有多个片段.在按钮上单击我开始一个新片段,将其添加到backstack.我自然希望调用onPause()
当前片段和onResume()
新片段的方法.好吧,它没有发生.
public class LoginFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.login_fragment, container, false);
final FragmentManager mFragmentmanager = getFragmentManager();
Button btnHome = (Button)view.findViewById(R.id.home_btn);
btnHome.setOnClickListener(new View.OnClickListener() {
public void onClick(View view){
HomeFragment fragment = new HomeFragment();
FragmentTransaction ft2 = mFragmentmanager.beginTransaction();
ft2.setCustomAnimations(R.anim.slide_right, R.anim.slide_out_left
, R.anim.slide_left, R.anim.slide_out_right);
ft2.replace(R.id.middle_fragment, fragment);
ft2.addToBackStack("");
ft2.commit();
}
});
}
@Override
public void onResume() {
Log.e("DEBUG", "onResume of LoginFragment");
super.onResume();
}
@Override
public void onPause() …
Run Code Online (Sandbox Code Playgroud) 有人可以告诉我如何在NSNotifcationCenter上使用object属性.我希望能够使用它将整数值传递给我的selector方法.
这就是我在UI视图中设置通知监听器的方法.看到我希望传递一个整数值,我不知道用什么代替nil.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveEvent:) name:@"myevent" object:nil];
- (void)receiveEvent:(NSNotification *)notification {
// handle event
NSLog(@"got event %@", notification);
}
Run Code Online (Sandbox Code Playgroud)
我从这样的另一个班级发出通知.该函数传递一个名为index的变量.这是我希望通过通知以某种方式启动的值.
-(void) disptachFunction:(int) index
{
int pass= (int)index;
[[NSNotificationCenter defaultCenter] postNotificationName:@"myevent" object:pass];
//[[NSNotificationCenter defaultCenter] postNotificationName:<#(NSString *)aName#> object:<#(id)anObject#>
}
Run Code Online (Sandbox Code Playgroud) 今天我发现了一件有趣的事情.我不知道在goto标签之后无法声明变量.
编译以下代码
#include <stdio.h>
int main() {
int x = 5;
goto JUMP;
printf("x is : %d\n",x);
JUMP:
int a = 0; <=== giving me all sorts of error..
printf("%d",a);
}
Run Code Online (Sandbox Code Playgroud)
给出错误
temp.c: In function ‘main’:
temp.c:7: error: expected expression before ‘int’
temp.c:8: error: ‘a’ undeclared (first use in this function)
temp.c:8: error: (Each undeclared identifier is reported only once
temp.c:8: error: for each function it appears in.)
Run Code Online (Sandbox Code Playgroud)
那背后的逻辑是什么?我听说无法在switch的case语句中创建变量.由于JUMP是goto语句的同一范围(主要功能的范围,在我的情况)里面,我相信,范围是不是一个问题在这里.但是,为什么我会收到此错误?
来自Android In App Billing版本3(TrivialDrive)的示例应用程序随附sdk
/* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
* (that you got from the Google Play developer console). This is not your
* developer public key, it's the *app-specific* public key.
*
* Instead of just storing the entire literal string here embedded in the
* program, construct the key at runtime from pieces or
* use bit manipulation (for example, XOR with some other string) to hide
* the actual key. The key itself …
Run Code Online (Sandbox Code Playgroud) 我正在开发iphone(iOS 4.0或更高版本)应用程序,并且在多个视图之间处理触摸问题.我有这样的视图结构
---> A superView
|
---> SubView - A
|
---> SubView - B (exactly on top of A, completely blocking A).
Run Code Online (Sandbox Code Playgroud)
基本上我有一个superView和兄弟子视图A和B. B与A具有相同的框架,因此完全隐藏了A.
现在我的要求就是这个.
这就是我为视图添加手势识别器的方法
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(leftSwipe:)];
[leftSwipe setDirection:(UISwipeGestureRecognizerDirectionLeft)];
leftSwipe.delegate = self;
[bView addGestureRecognizer:leftSwipe];
[leftSwipe release];
UISwipeGestureRecognizer *rightSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(rightSwipe:)];
[rightSwipe setDirection:(UISwipeGestureRecognizerDirectionRight)];
rightSwipe.delegate = self;
[bView addGestureRecognizer:rightSwipe];
[rightSwipe release];
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(handlePinch:)];
pinch.delegate = self;
[aView addGestureRecognizer:pinch];
[pinch release];
Run Code Online (Sandbox Code Playgroud)
我做了一些研究,对我UIGestureRecognizerDelegate
看起来很有希望,我实现了委托方法
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer …
Run Code Online (Sandbox Code Playgroud) 我有一个包含多个子视图的视图.当用户点击子视图时,子视图的大小会扩展到大部分屏幕,但其他一些子视图仍然可以在下面看到.
当其中一个子视图像这样"扩展"时,我希望我的应用忽略其他子视图上的触摸.有没有一种简单的方法来实现这一目标?我可以编写代码来处理这个,但我希望有一个更简单的内置方式.
在我的iPhone项目中集成Zxing,QR码阅读器框架.我从这里检查了ZXing sdk .我运行了ZXing的示例项目,名为ScanTest,没有任何问题.但是当我尝试将库与我的项目集成时,我收到了提到的错误.
当我构建时,在完成ZXing自述文件中的每个集成步骤后,我都会遇到构建错误
Undefined symbols for architecture armv7:
"std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
zxing::qrcode::Detector::computeDimension(zxing::Ref<zxing::ResultPoint>, zxing::Ref<zxing::ResultPoint>, zxing::Ref<zxing::ResultPoint>, float) in libZXingWidget.a(Detector-B8B28E953F840D47.o)
Undefined symbols for architecture armv7:
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
zxing::Exception::Exception(char const*) in libZXingWidget.a(Exception.o)
zxing::common::StringUtils::guessEncoding(unsigned char*, int, std::map<unsigned int, std::string, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, std::string> …
Run Code Online (Sandbox Code Playgroud) 我正在创建一个bash脚本,除其他外,它从MySQL数据库中收集一些数据.我的MySQL用户具有写权限,但出于安全考虑,我想暂时将其设置为只读状态.是否可以从命令行执行此操作?
我想用Quartz 2D绘制文字."菜单"方向错误.我希望"菜单"仍然可读,并且与X轴有45度.以下是我的代码:
CGContextSelectFont(context, "Arial", 12, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 0, 0, 0, 1); // 6
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
CGContextSetTextMatrix(context, CGAffineTransformMakeRotation(45));
CGContextShowTextAtPoint(context,10, 10, "Menu", 4);
Run Code Online (Sandbox Code Playgroud) ios ×4
android ×3
cocoa-touch ×3
iphone ×3
back-stack ×1
c ×1
cocoa ×1
command-line ×1
goto ×1
hide ×1
ios6 ×1
ipad ×1
java ×1
mysql ×1
objective-c ×1
onresume ×1
public-key ×1
quartz-2d ×1
readonly ×1
security ×1
shell ×1
show ×1
touch ×1
uiview ×1
zxing ×1