在我的应用程序中,我正在进行一些计算.整个布局位于Scrollview内.
结果显示在顶部.Xml是这样的:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/back2back"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="526dp"
android:background="@drawable/back4"
android:orientation="vertical" >
<TextView
android:id="@+id/nothing"
android:layout_width="181dp"
android:layout_height="51dp"
android:layout_gravity="center"
android:textColor="#000000"
android:textStyle="bold" />
rest of the xml
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
所以我想按下计算按钮时,屏幕的焦点将设置在我的页面顶部(或者在上部文本视图中更具体),这样用户就能看到结果.我在搜索过但我找不到类似的东西.
可能重复:
您如何测试iPhone应用程序?
在Android中,您可以导出您的应用并获取可以安装在任何手机上进行测试的.apk文件.这可能与Xcode和iOS有关吗?我的意思是,我被分配了一份工作,我想发送我的第一个演示.
我的问题如下:
1)我应该寄什么?是否有与.apk文件类似的东西?
2)我知道发布应用程序的过程.如果我只是想发送测试,我是否必须创建一个分发配置文件和所有工作人员?问题是最终的应用程序不会从我的开发者帐户发布,而是从员工的帐户发布.那是问题吗?
3)我将发送文件的人是否需要Xcode来运行应用程序或其他什么?在付钱给我之前,我不想把他的代码寄给他.
我正在整合Facebook与Android,我想拍摄时,将其保存到SD卡,然后将其上传到Facebook.
这是我的代码:
photo_up=(Button)findViewById(R.id.camera_foto_button);
photo_up.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(PlaceScreen.this)) );
startActivityForResult(intent,CAMERA_REQUEST);
}
});
private File getTempFile(Context context){
//it will return /sdcard/image.tmp
final File path = new File( Environment.getExternalStorageDirectory(), context.getPackageName() );
if(!path.exists()){
path.mkdir();
}
return new File(path, "image.png");
}
Run Code Online (Sandbox Code Playgroud)
和OnActivity结果
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode){
case CAMERA_REQUEST:{
final File file = getTempFile(this);
try {
bmp = MediaStore.Images.Media.getBitmap(this.getContentResolver(), Uri.fromFile(file) );
// do whatever you want with the …Run Code Online (Sandbox Code Playgroud) 我需要你的帮助.我对C有一个平均的知识,这就是问题所在.我将使用一些基准来测试新处理器上的一些计算机体系结构(分支未命中,缓存未命中).关于它的事情是基准测试在C中,但我不能包含任何库调用.例如,我不能使用malloc因为我收到了错误
"undefined reference to malloc"
Run Code Online (Sandbox Code Playgroud)
即使我已经包括了图书馆.所以我必须编写自己的malloc.我不希望它超级高效 - 只需要做基础知识.正如我在想的那样,我必须在内存中有一个地址,并且每当malloc发生时,我都会返回一个指向该地址的指针并按该大小递增计数器.Malloc在我的程序中发生了两次,所以我甚至不需要大内存.
你能帮帮我吗?我设计了一个Verilog并且在C中没有那么多经验.
我见过以前的答案但对我来说似乎都太复杂了.此外,我无法访问KR书.
干杯!
编辑:也许这可以帮助你更多:我不是使用gcc而是使用sde-gcc编译器.它有什么不同吗?也许这就是为什么我得到一个未定义的malloc引用?
EDIT2:我正在测试MIPS架构:
我包括:
#include <stdlib.h>
Run Code Online (Sandbox Code Playgroud)
而错误是:
undefined reference to malloc
relocation truncated to fit: R_MIPS_26 against malloc
Run Code Online (Sandbox Code Playgroud)
和编译器命令id:
test.o: test.c cap.h
sde-gcc -c -o test.s test.c -EB -march=mips64 -mabi=64 -G -O -ggdb -O2 -S
sde-as -o test.o test.s EB -march=mips64 -mabi=64 -G -O -ggdb
as_objects:=test.o init.o
Run Code Online (Sandbox Code Playgroud)
编辑3:好的,我使用上面的实现,它运行没有任何问题.问题是,在进行嵌入式编程时,您只需定义所使用的所有内容,因此我定义了自己的malloc.sde-gcc无法识别malloc函数.
我希望你的帮助应该很容易,我不知道为什么它不起作用.我想从bin中读取第一个数据,我知道它是一个int.我正在使用以下部分代码,但我收到了分段错误:
int main(int argc, char **argv)
{
int *data;
/*opening file*/
FILE *ptr_myfile;
ptr_myfile=fopen(myfile.bin","rb");
if (!ptr_myfile)
{
printf("Unable to open file!\n");
return 1;
}
/*input file opened*/
printf("I will read the first 32-bit number\n");
/*will read the first 32 bit number*/
fread(&data,sizeof(int),1, ptr_myfile);
printf("Data read is: %d\n",*data);
fclose(ptr_myfile);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过这样称呼它:
fread(data,sizeof(int),1, ptr_myfile);
Run Code Online (Sandbox Code Playgroud)
它应该是指针的东西,但我看不到什么.
在我的IOS应用程序中,我正在实现地理围栏.在当前的实现中,我使用的代码如下:
CLRegion* region3 = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:100 identifier:@"region3"];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyHundredMeters];
Run Code Online (Sandbox Code Playgroud)
然后我使用这些委托方法:
(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
NSLog(@"didenterregion");
}
(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region{
NSLog(@"didexitregion");
}
(void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{NSLog(@"monitoringDidFailForRegion");}
Run Code Online (Sandbox Code Playgroud)
但是,此代码仅适用于大于100米的半径.
以下是一些问题:
我也想到了.Apple表示可以支持多达20个地区.像这样的溶剂有什么优点/缺点(我还没有实现,但我想要你的意见).
伪代码将是这样的:
Declare the regions - save them in an array
Do not call start monitoring
Run Code Online (Sandbox Code Playgroud)
然后在委托方法中:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
for loop in all my regions {
if ([region containsCoordinate: newLocation.coordinate])
code for entering region
}
}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码以模态方式呈现视图控制器:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SubmitAYoNViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"SubmitAYoN"];
[ivc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:ivc animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
然后在我的 SubmitAYoNViewController 中我有这个:
NSLog(@"%@",self.parentViewController);
if([self.parentViewController isKindOfClass:[YesOrNoViewController class]]) {
NSLog(@"do something");
}
Run Code Online (Sandbox Code Playgroud)
self.parentVeiwController 为 NULL。这是为什么?
编辑:我想从我的父视图控制器访问一种方法,然后访问打开 SubmitAYoN 的方法。
解决方案:我使用委托代替。根据下面的答案,presentViewController 不会创建父子关系。
我有一些const/mutable和protected的问题.也许这些让我感到困惑所以我会举一个例子.
class Base
{
virtual void foo() const ;
protected :
void bar( int y ){ d_x = y } ;
private :
mutable int d_x ;
}
Run Code Online (Sandbox Code Playgroud)
所以基类有虚拟foo.
class Derived : public Base
{
void foo() const { bar(5); }
private :
mutable int d_x ;
}
Run Code Online (Sandbox Code Playgroud)
所以在我的派生类中,我实现了foo哪个类bar然后写入私有d_x.
我认为很好 - 但编译器说:
passing 'Derived' as 'this' argument of bar discards qualifier.
Run Code Online (Sandbox Code Playgroud)
这是为什么?我认为通过使用mutable我可以使我的成员函数成为const.
这个作品
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
Run Code Online (Sandbox Code Playgroud)
但这不是:
sudo -s 'echo /usr/local/bin/zsh >> /etc/shells'
/bin/bash: echo /usr/local/bin/zsh >> /etc/shells: No such file or directory
Run Code Online (Sandbox Code Playgroud) 我能够做大部分我能做的事,但不是全部。
如果我有 :
\d+ myschema.mytable
Run Code Online (Sandbox Code Playgroud)
我列出了所有列和索引。索引的格式例如:
Indexes:
"id_pkey" PRIMARY KEY, btree (id,name,timestamp)
"ix05_id" btree (name,company)
Run Code Online (Sandbox Code Playgroud)
我能够通过sql以及有关索引和键的列来获取信息,我已经从上面的帖子中找到了一些sql,但是并不能完全采用这种格式。
因此对于键,我能够做到:
SELECT
pg_attribute.attname,
format_type(pg_attribute.atttypid, pg_attribute.atttypmod)
FROM pg_index, pg_class, pg_attribute, pg_namespace
WHERE
pg_class.oid = 'mytable'::regclass AND
indrelid = pg_class.oid AND
nspname = 'myschema' AND
pg_class.relnamespace = pg_namespace.oid AND
pg_attribute.attrelid = pg_class.oid AND
pg_attribute.attnum = any(pg_index.indkey)
AND indisprimary
Run Code Online (Sandbox Code Playgroud)
因此,这一行获取键所适用的列,而不是索引/键的名称?如何在上面的查询中添加呢?我需要加入什么桌子?
对于索引,我能够做到
SELECT * FROM pg_indexes WHERE tablename = 'mytable' AND schemaname = 'myschema' ;
Run Code Online (Sandbox Code Playgroud)
哪个获取索引,但未明确列出它们适用的列-我只看到indexdef是如何创建的?我可以通过与其他表连接来获取该信息,还是必须解析indexdef并获取适用于该列的索引?