2017-11-29 1 views
-3

Android Studio로 앱을 제작하고 있지만 ToolBar를 표시 할 수 없습니다. 이 내 AndroidManifest.xml을내 애플리케이션에 툴바를 표시하는 방법은 무엇입니까?

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.mcsolution.easymanagementandroid"> 

    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme" > 
    <activity 
      android:name="com.mcsolution.easymanagementandroid.main.MainActivity" 
      android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity android:name="com.mcsolution.easymanagementandroid.main.nuovoOrdine"></activity> 
     <activity android:name="com.mcsolution.easymanagementandroid.ordine.creaOrdine"></activity> 
     <activity android:name="com.mcsolution.easymanagementandroid.ordine.mainOrdine"></activity> 
     <activity android:name="com.mcsolution.easymanagementandroid.ordine.viewOrdine"></activity> 
     <activity 
      android:name="com.mcsolution.easymanagementandroid.setting.setting" 
      android:label="@string/app_name" 
      android:windowSoftInputMode="stateVisible|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
     <activity android:name="com.mcsolution.easymanagementandroid.articoli.viewArticoli" 
      android:windowSoftInputMode="stateVisible|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
     <activity android:name="com.mcsolution.easymanagementandroid.clienti.mainClienti" 
      android:windowSoftInputMode="stateVisible|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
     <activity android:name="com.mcsolution.easymanagementandroid.clienti.viewClienti" 
      android:windowSoftInputMode="stateVisible|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
     <activity android:name="com.mcsolution.easymanagementandroid.clienti.infoCliente" 
      android:windowSoftInputMode="stateHidden|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
     <activity android:name="com.mcsolution.easymanagementandroid.clienti.operazioniCliente" 
      android:windowSoftInputMode="stateHidden|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
     <activity android:name="com.mcsolution.easymanagementandroid.clienti.operazioniClienteDettaglio" 
      android:windowSoftInputMode="stateHidden|adjustResize" 
      android:configChanges="orientation|screenSize"/> 
    </application> 

</manifest> 

어떻게 도구 모음을 표시 할 수있다?

EDIT 이것은

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:background="@color/cardview_dark_background"> 


    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/articoli" 
       android:onClick="visualizzaArticoli" 
       android:background="@null"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Articoli" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp"/> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/order" 
       android:onClick="creaOrdine" 
       android:background="@null"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/ordini" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp"/> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/customer" 
       android:onClick="viewClienti" 
       android:background="@null"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/cliente" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp"/> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/sincronizza" 
       android:onClick="allineaDatase" 
       android:background="@null"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/allinea_database" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp"/> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/setting" 
       android:onClick="setting" 
       android:background="@null"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/impostazioni" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp"/> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 



</LinearLayout> 

패키지 com.mcsolution.easymanagementandroid.main 주요 활동이고;

import android.app.Activity; 
import android.app.ProgressDialog; 
import android.content.Intent; 
import android.content.pm.PackageManager; 
import android.content.pm.ResolveInfo; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.Menu; 
import android.view.View; 
import android.widget.Toast; 

import com.mcsolution.easymanagementandroid.R; 
import com.mcsolution.easymanagementandroid.beans.Program; 
import com.mcsolution.easymanagementandroid.connection.MyDatabase; 
import com.mcsolution.easymanagementandroid.utility.SyncDati; 

public class MainActivity extends Activity { 
    public MyDatabase db; 
    public ProgressDialog dialog; 
    public String url=""; 
    private static final Intent SCAN_INTENT = new Intent("com.google.zxing.client.android.SCAN"); 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     //RelativeLayout layout = (RelativeLayout)findViewById(R.id.root); 
     // layout.setBackgroundColor(getResources().getColor(Color.BLUE)); 

     PackageManager packageManager = this.getPackageManager(); 
     @SuppressWarnings("unused") 
     ResolveInfo resolveInfo = packageManager.resolveActivity(SCAN_INTENT, PackageManager.GET_RESOLVED_FILTER); 
     //  if(resolveInfo==null) { 
     //   ((Button)this.findViewById(R.id.scanButton)).setEnabled(false); 
     //   ((TextView)this.findViewById(R.id.scanResult)).setText("Non hai installato nessuna applicazione per effettuare lo scan!!!\nScaricala qui: http://www.appbrain.com/app/com.google.zxing.client.android"); 
     //  } 

    } 

    public void onScan(View view) { 
     startActivityForResult(SCAN_INTENT, 0); 
    } 

    private void apriConnessioneDB(){ 
     db=new MyDatabase(getApplicationContext()); 
     db.open(); //apriamo il db 
    } 
    @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 void visualizzaArticoli(View view){ 
     Intent intent = new Intent(this, com.mcsolution.easymanagementandroid.articoli.viewArticoli.class); 
     startActivity(intent); 
    } 
    public void viewClienti(View view){ 
     Intent intent = new Intent(this, com.mcsolution.easymanagementandroid.clienti.mainClienti.class); 
     startActivity(intent); 
    } 

    public void creaOrdine(View view){ 
     Intent intent = new Intent(this, com.mcsolution.easymanagementandroid.ordine.mainOrdine.class); 
     startActivity(intent); 
    } 
    public void setting(View view){ 
     Intent intent = new Intent(this, com.mcsolution.easymanagementandroid.setting.setting.class); 
     startActivity(intent); 
    } 
    public void allineaDatase(View view){ 
     try{ 

     }catch(Exception e){ 
      e.printStackTrace(); 
      Toast.makeText(this, e.getMessage(), 
        Toast.LENGTH_LONG).show(); 
     } 

    } 


} 
+0

및 Java 파일. 여기서 툴바를 초기화합니다. –

답변

0

아마 styles.xmlAppThemeNoActionbar

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

처럼 아래

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 
1
에 확인 Theme에있다
Use android.support.v7.widget.Toolbar 




<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent"`enter code here` 
    android:layout_height="match_parent" 
    android:background="@color/cardview_dark_background" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?actionBarSize" 
     android:background="@android:color/white" 
     app:contentInsetStart="0dp"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_centerInParent="true" 
       android:gravity="center" 
       android:text="Toolbar title" 
       android:textColor="@android:color/black" /> 


     </RelativeLayout> 

    </android.support.v7.widget.Toolbar> 


    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@null" 
       android:onClick="visualizzaArticoli" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp" 
       android:text="Articoli" /> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@null" 
       android:onClick="creaOrdine" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp" 
       android:text="@string/app_name" /> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@null" 
       android:onClick="viewClienti" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp" 
       android:text="@string/app_name" /> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@null" 
       android:onClick="allineaDatase" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp" 
       android:text="@string/app_name" /> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     card_view:cardBackgroundColor="@color/cardview_light_background"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@null" 
       android:onClick="setting" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="50dp" 
       android:text="@string/app_name" /> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    enter code here 

</LinearLayout> 
당신은 당신의 mainActivity.xml처럼, 자세한 내용을 게시해야합니다
관련 문제