找不到appcompat v7源代码

时间:2014-05-12 08:57:31

标签: android android-appcompat

我开发了我的应用程序。我想让我的应用程序与姜饼兼容。 这是我的代码...我已经用资源导入了库appcompat-v7 MainActivity:

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;

public class MainActivity extends ActionBarActivity  {

    ViewPager Tab;
    TabPagerAdapter TabAdapter;
    ActionBar actionBar;
    public boolean StatusConnection = false;
    public int thread = 0;


    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); 


        TabAdapter = new TabPagerAdapter(getSupportFragmentManager()); 
        Tab = (ViewPager)findViewById(R.id.pager); 
        Tab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

                    @Override
                    public void onPageSelected(int position) {
                        actionBar.setSelectedNavigationItem(
                                position);
                        Tab.setCurrentItem(position);
                    }

                });
        Tab.setAdapter(TabAdapter); 

        actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        ActionBar.TabListener tabListener = new ActionBar.TabListener(){

            @Override
            public void onTabReselected(ActionBar.Tab arg0,FragmentTransaction arg1) {
                // TODO Auto-generated method stub

            }
            @Override
            public void onTabSelected(ActionBar.Tab arg0,FragmentTransaction arg1) {
                // TODO Auto-generated method stub
                Tab.setCurrentItem(arg0.getPosition());
            }
            @Override
            public void onTabUnselected(ActionBar.Tab arg0,FragmentTransaction arg1) {
                // TODO Auto-generated method stub

            }
        }; 

        actionBar.addTab(actionBar.newTab().setText("a").setTabListener(tabListener));
        actionBar.addTab(actionBar.newTab().setText("b").setTabListener(tabListener));
        actionBar.addTab(actionBar.newTab().setText("c").setTabListener(tabListener));

        if (!isOnline()){
            try {

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("Connessione Internet")
                .setMessage("Connessione Internet non disponibile.")
                .setCancelable(false)
                .setNegativeButton("Esci",new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        finish();
                    }
                });
                AlertDialog alert = builder.create();
                alert.show();
            }
            catch(Exception e) { }
        }
    }

    private class TabPagerAdapter extends FragmentStatePagerAdapter {

        public TabPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
            switch (i) {
                case 0:
                    return new info();
                case 1:
                    return Arrivi.newInstance(thread, A_Compagnia, A_CodiceVolo, A_Citta, A_OraPrevista, A_OraStimata, A_StatoVolo); 
                case 2:
                    return Partenze.newInstance(thread, P_Compagnia, P_CodiceVolo, P_Citta, P_OraPrevista, P_OraStimata, P_StatoVolo); 

            }
            return null;
        }

        @Override
        public int getCount() {
            return 3;
        }
    }

代码中没有错误,但是当我运行应用程序崩溃时。 LogCat为空。 我明白了:http://imagebin.org/310360"找不到来源" !?!?! 这是我的项目:http://imagebin.org/310365

任何人都可以帮助我吗???? :(

1 个答案:

答案 0 :(得分:5)

好像你刚刚导入了jar文件,而不是整个项目作为库。

将整个appcompat lib(/ extras / android / support / v7 / appcompat)作为库项目导入工作区,然后作为库添加到主项目中。