1

我正在android上设置我的第一个metaio sdk应用程序,当我执行项目时,相机图像显示在主活动中,但如果我添加一个按钮,则不显示。这是主要的活动代码

package pfg.proyecto.com.proyecto;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

import com.metaio.sdk.ARViewActivity;
import com.metaio.sdk.MetaioDebug;
import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.IMetaioSDKCallback;
import com.metaio.tools.io.AssetsManager;

import java.io.IOException;


public class MainActivity extends ARViewActivity {

@Override
protected int getGUILayout() {
    return 0;
}

@Override
protected IMetaioSDKCallback getMetaioSDKCallbackHandler() {
    return null;
}

@Override
protected void loadContents() {

}

@Override
protected void onGeometryTouched(IGeometry geometry) {

}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    new LoadAssets().execute();
    boolean result = metaioSDK.setTrackingConfiguration("GPS", false);
    MetaioDebug.log("Tracking data loaded: " + result);
}


/*@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}*/

public class LoadAssets extends AsyncTask<Void, Integer, Boolean> {
    @Override
    protected Boolean doInBackground(Void... params) {
        try
        {
            // Extract all assets and overwrite existing files if debug build
            AssetsManager.extractAllAssets(getApplicationContext(), BuildConfig.DEBUG);
            return true;
        }
        catch (IOException e)
        {
            MetaioDebug.log(Log.ERROR, "Error extracting assets: " + e.getMessage());
            MetaioDebug.printStackTrace(Log.ERROR, e);
            return false;
        }
    }
}
}

我错过了什么?

4

2 回答 2

1

您需要在返回 0 的 getGUILayout 方法中返回布局文件,只需将值更改为 R.layout。布局 XML 文件的名称

于 2015-03-03T01:05:05.750 回答
0

它应该是这样的 protected int getGUILayout() { return R.layout.my_layout; }

然后在 my_layout 中添加按钮

于 2015-05-19T07:51:45.947 回答