我正在Android上设置我的第一个metaio sdk应用程序,当我执行proyect时,主要活动中会显示摄像机图像但是如果我添加了一个按钮,则不会显示。 这是主要的活动代码
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;
}
}
}
}
我错过了什么?
答案 0 :(得分:1)
你需要在getGUI Layout方法中返回布局文件而不是返回0只需将值更改为R.layout.the布局XML文件的名称
答案 1 :(得分:0)
它应该是这样的 protected int getGUILayout() { 返回R.layout.my_layout; }
然后在my_layout中添加按钮