以下是我的代码,其中“DrawerView抽屉”的部分是我的问题,您可以看到here 上面的部分让我导入support.v4.widget.DrawerLayout,但这里没有任何我可以导入的内容。
我仍然是Android开发人员的新手,对不起,如果我在这里做错了什么
package com.nath.thecompletembguide;
import com.kskkbys.rate.RateThisApp;
import com.startapp.android.publish.SDKAdPreferences;
import com.startapp.android.publish.SDKAdPreferences.Gender;
import com.startapp.android.publish.StartAppSDK;
import android.net.Uri;
import android.os.Bundle;
import android.content.Intent;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {
@Override
protected void onStart() {
super.onStart();
// Monitor launch times and interval from installation
RateThisApp.onStart(this);
// If the criteria is satisfied, "Rate this app" dialog will be shown
RateThisApp.showRateDialogIfNeeded(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StartAppSDK.init(this, "105864370", "207677226", new SDKAdPreferences().setAge(10).setGender(Gender.MALE), false);
setContentView(R.layout.activity_main);
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
DrawerView drawer = (DrawerView) findViewById(R.id.drawer);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
if(android.R.id.home == item.getItemId()){
finish();
return super.onOptionsItemSelected(item);
}
switch (item.getItemId())
{
case R.id.action_upgrade:
Intent launchNewIntent = new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=com.nath.thecompletembguidepro"));
startActivity(launchNewIntent);
return true;
case R.id.action_about:
Intent launchNewIntent3 = new Intent(MainActivity.this, MainActivity.class);
startActivity(launchNewIntent3);
return true;
case R.id.action_credits:
Intent launchNewIntent1 = new Intent(MainActivity.this,MainActivity.class);
startActivityForResult(launchNewIntent1, 0);
return true;
case R.id.action_changelogs:
Intent launchNewIntent2 = new Intent("android.intent.action.VIEW", Uri.parse("http://nathcraft.com"));
startActivity(launchNewIntent2);
Toast.makeText(MainActivity.this, "Requires Network Connection", Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}}}
答案 0 :(得分:1)
许多库(可能是因为android studio ...)使用java
文件夹作为src
文件夹...将eclipse中库中的所有代码从'java'文件夹移动到src
文件夹,之后清理并重建库,然后刷新自己的项目,应解决问题......
答案 1 :(得分:0)
就我所见,你的进口看起来很好。 DrawerView不是一件好事。 :)
不幸的是,需要很多样板代码才能使导航抽屉正常工作。但是,幸运的是,有很多例子。
一个很好的参考是Google IO应用程序,它由Roman Nurik和团队编写,他们也提供了所有源代码。
您感兴趣的是布局XML资源和源代码:
布局XML(向下滚动到" navdrawer") https://github.com/google/iosched/tree/dfaf8b83ad1b3e7c8d1af0b08d59caf4223e0b95/android/src/main/res/layout
下载应用程序: https://play.google.com/store/apps/details?id=com.google.samples.apps.iosched
答案 2 :(得分:0)
我也在Eclipse中使用它:我已经在我自己的项目中复制了所有Heinrich的软件包及其布局,值......并且它到目前为止似乎工作正常。好吧,我有一个问题,我不是唯一的问题:个人资料不显示,只有项目