2014-12-18 4 views
0

나는 안드로이드 개발을 처음 접하고 다른 프로젝트에서 XML 레이아웃을 복사하려고 시도했지만 그 그래픽 레이아웃은 내가 얻고있는 것과는 다른 것으로 보인다. 나는 내 프로젝트에서 내가 같은 레이아웃을 얻지 못하고 있다는 것을 모른다. 도와주세요.동일한 XML 코드, 다른 그래픽 레이아웃

이 모양은 다음과 같습니다.

! 1

이 코드는 정확한 코드를 복사 한 후 가져옵니다.

! 2

내 xml 파일

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.aditya.contentsharer" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="11" 
     android:targetSdkVersion="21" /> 

    <uses-permission android:name="android.permission.CAMERA" /> 

    <uses-feature android:name="android.hardware.camera" /> 

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

    <application 
     android:name=".InteriorSpottingApplication" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 

     <activity 
      android:name=".InteriorListActivity" 
      android:label="@string/title_activity_interior_list" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value="android.app.Activity" /> 
     </activity> 
     <activity 
      android:name=".NewInteriorActivity" 
      android:label="@string/title_activity_new_interior" > 
     </activity> 
    </application> 

</manifest> 

XML 코드

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/fragmentContainer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    /> 

자바 코드

package com.aditya.contentsharer; 

import android.app.Activity; 
import android.app.ListActivity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 

import com.parse.ParseQueryAdapter; 

public class InteriorListActivity extends ListActivity{ 

    private ParseQueryAdapter<Interior> mainAdapter; 
    private FavoriteInteriorAdapter favoritesAdapter; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     getListView().setClickable(false); 

     mainAdapter = new ParseQueryAdapter<Interior>(this, Interior.class); 
     mainAdapter.setTextKey("title"); 
     mainAdapter.setImageKey("photo"); 

     // Subclass of ParseQueryAdapter 
     favoritesAdapter = new FavoriteInteriorAdapter(this); 

     // Default view is all interiors 
     setListAdapter(mainAdapter); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     getMenuInflater().inflate(R.menu.activity_interior_list, menu); 
     return true; 
    } 

    /* 
    * Posting interiors and refreshing the list will be controlled from the Action 
    * Bar. 
    */ 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     switch (item.getItemId()) { 

     case R.id.action_refresh: { 
      updateinteriorList(); 
      break; 
     } 

     case R.id.action_favorites: { 
      showFavorites(); 
      break; 
     } 

     case R.id.action_new: { 
      newinterior(); 
      break; 
     } 
     } 
     return super.onOptionsItemSelected(item); 
    } 

    private void updateinteriorList() { 
     mainAdapter.loadObjects(); 
     setListAdapter(mainAdapter); 
    } 

    private void showFavorites() { 
     favoritesAdapter.loadObjects(); 
     setListAdapter(favoritesAdapter); 
    } 

    private void newinterior() { 
     Intent i = new Intent(this, NewInteriorActivity.class); 
     startActivityForResult(i, 0); 
    } 

    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (resultCode == Activity.RESULT_OK) { 
      // If a new post has been added, update 
      // the list of posts 
      updateinteriorList(); 
     } 
    } 

} 
+0

맨 위에 해당 작업 표시 줄을 표시해야합니다. –

+0

레이아웃에서 holo.light 테마를 사용하여 작업 표시 줄을 가져올 수 있었지만 장치에서 실행할 때 여전히 표시되지 않습니다. –

답변

0

나는 해결책을 얻었다. 매니페스트 파일에서 android : theme = "@ style/AppTheme"을 삭제했습니다. 그것은 저를 위해 잘 일했습니다.

0

나는 보통 ListActivities를 사용하지 않는다. 왜냐하면 나는 평소에 ListView를 사용했기 때문에 처음에는 onCreate() 메서드에서 실제로 레이아웃을 가져올 필요가있다. ...

setContentView(R.layout.fragmentContainer); 

(XML 파일을 가정하는 것은 바로 ID를의 같은 이름을 가진?

내가하지 오전

super.onCreate(savedInstanceState); 

후 퍼팅 시도 쉬르 그것이 작동하지만 시도해보십시오! :)

관련 문제