3
我試圖cardslib我的項目。我按照文檔添加了依賴項,但仍然出現「無法解析符號卡」,「無法解析符號卡頭」錯誤。無法解析的符號卡,Android工作室依賴錯誤
MainActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
ArrayList<Card> cards = new ArrayList<Card>();
//Create a Card
Card card = new Card(getContext());
//Create a CardHeader
CardHeader header = new CardHeader(getContext());
....
//Add Header to card
card.addCardHeader(header);
cards.add(card);
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(),cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.myList);
if (listView!=null){
listView.setAdapter(mCardArrayAdapter);
}
}
fragment_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">
<it.gmariotti.cardslib.library.view.CardListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myList"/>
</RelativeLayout>
的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
}
dependencies {
compile 'com.github.gabrielemariotti.cards:library:0.6.0'
}
我認爲工具欄上有按鈕來強制Android Studio重新讀取Gradle構建文件中的依賴關係 –
是的,該按鈕位於avd按鈕的左側。 –
我在搜索後遇到了這個問題,因爲我遇到過類似的問題,而且我正在使用intelij。我試圖將源文件複製到我的項目中的庫文件夾,並且還需要maven依賴項才能從repo下載它,並且我無法使其工作。請讓我知道你是否能夠使這個圖書館工作和你採取的步驟。謝謝 – ez4nick