小编Sku*_*del的帖子

编译Hello World

我正在从一个简单的"hello world"教程开始,然后将其修改为我想要的应用程序.我开始用一个hello world app添加了一个按钮,现在我正在尝试响应按钮事件等.

但是当我编译时,我收到错误:"package andriod.widget不存在\n import andriod.widget.Button;"

代码是

package com.luke.bowls;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import andriod.widget.Button;

public class Bowls extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
                final Button button = (Button)findViewById(R.id.android_button);
                button.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        // Perform action on clicks
                    }
                });
    }
}
Run Code Online (Sandbox Code Playgroud)

它看起来像一个库引用问题,但大多数构建代码是隐藏的,所以我不知道该怎么做来解决它.

java android

2
推荐指数
1
解决办法
365
查看次数

在赋值表达式中找不到明确定义的setter

对于Scala属性,我有一个小难题.

各种博客和教程告诉我这个:

class Something
{
    var foo = 1
}
Run Code Online (Sandbox Code Playgroud)

......可以指定为......

class Something
{
    private var _field = 1

    def foo = _field
    def foo_(foo: Int) = _field = foo
}
Run Code Online (Sandbox Code Playgroud)

这对我来说非常有意义,在进行赋值时,编译器会查找name_方法.问题是它似乎对我不起作用.

在下面的真实代码中(同样的事情也发生在其他类中):

class Camera
{
  private var _position = Vector2.zero

  def position: Vector2 = _position
  def position_(position: Vector2) =
  {
    // Do boring transforms.
    _position = position // position shadows outer scope so this does work.
  }
}

// ...
val camera = new Camera
camera.position = …
Run Code Online (Sandbox Code Playgroud)

scala properties

2
推荐指数
2
解决办法
146
查看次数

在结构中初始化数组变量

我最后这样做了,

struct init
{
    CHAR Name[65];
};

void main()
{
    init i;

    char* _Name = "Name";

    int _int = 0;

    while (_Name[_int] != NULL)
    {
        i.Name[_int] = _Name[_int];
        _int++;
    }
}
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
729
查看次数

让 C 在 _Generic 中生成错误

我一直在研究一些代码(与线性代数相关)。我有多种类型,它们应该能够相互相乘。

我自然地想到“让我们使用 _Generic”来实现这一点。只要参数类型的组合有效,它就可以工作。根据搜索引擎,一些库诉诸于使用虚拟函数的属性来生成错误:

#include "stdio.h"

// Example struct.
typedef struct mat3_s
{
    float m[9];
} mat3;

// Dummy function.
mat3 mult(mat3 const *A, mat3 const *B)
{   
    return *A;
}

mat3 mults(mat3 const *A, float const *B)
{
    return *A;
}

typedef mat3 (*dummyptr)(void *A, void *B);
extern dummyptr INCOMPATIBLE_TYPES() __attribute__((error("Crikey"))); 

#define LMULT(A, B)\
    _Generic((A),\
    mat3: \
        _Generic((B),\
            mat3: mult, \
            float: mults, \
            default: INCOMPATIBLE_TYPES()),\
    default: INCOMPATIBLE_TYPES()) (&(A), &(B))

int main(int argc, char *argv[])
{
    mat3 a = {{0}}; …
Run Code Online (Sandbox Code Playgroud)

c generics macros c11

1
推荐指数
1
解决办法
402
查看次数

如何在win32中的C编程中将char*转换为unsigned int

我想转换char*str ="10.20.30.40"; in to unsigned int.你可以告诉我任何方法或任何示例代码.请跟我分享一下

c string unsigned integer

0
推荐指数
1
解决办法
1267
查看次数

标签 统计

c ×2

android ×1

c++ ×1

c11 ×1

generics ×1

integer ×1

java ×1

macros ×1

properties ×1

scala ×1

string ×1

unsigned ×1