Soru & Cevap

ListView Görüntüleme Sorunu ...

28.05.2014 - 02:30

Herkese merhaba;

Dropbox benzeri bir arayuz tasarlamaktayım. Uygulamada TabHost aracını kullanıyorum. 1.sekmede dosyalar yer alacak. Dosya listeisini görüntülemeye çalışıyorum, hiçbir hata almama rağmen liteyi görüntüleyemiyorum. Kodlar Aşağıda;

MainActivity.java

[code]

package com.example.arayuz;

import java.util.ArrayList;
import java.util.List;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.os.Build;
import com.example.arayuz.*;

public class MainActivity extends TabActivity {
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        TabHost tbHost = getTabHost();
        TabHost.TabSpec sekme;
        Intent t;
        
        t = new Intent(this,Sayfa1.class);
        sekme = tbHost.newTabSpec("sekme1").setIndicator("",
                getResources().getDrawable(R.drawable.utilities_file_archiver)).setContent(t);
        tbHost.addTab(sekme);
        
        t = new Intent(this,Sayfa2.class);
        sekme = tbHost.newTabSpec("sekme2").setIndicator("",
                getResources().getDrawable(R.drawable.star)).setContent(t);
        tbHost.addTab(sekme);
        
        t = new Intent(this,Sayfa3.class);
        sekme = tbHost.newTabSpec("sekme1").setIndicator("",
                getResources().getDrawable(R.drawable.bell)).setContent(t);
        tbHost.addTab(sekme);
        
        t = new Intent(this,Secenekler.class);
        sekme = tbHost.newTabSpec("sekme1").setIndicator("",
                getResources().getDrawable(R.drawable.settings)).setContent(t);
        tbHost.addTab(sekme);

    }
}

[/code]

activity_main.xml

[code]

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.arayuz.MainActivity"
    tools:ignore="MergeRootFrame" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" 
            android:layout_alignParentLeft="true">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                
                android:orientation="horizontal"
                android:tabStripEnabled="@bool/abc_config_showMenuShortcutsWhenKeyboardPresent" >

            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal" >

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal" >

                    <Gallery
                        android:id="@+id/gallery1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal" >
                </LinearLayout>
                
                <LinearLayout
                    android:id="@+id/tab4"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal" >
                </LinearLayout>

            </FrameLayout>
        </LinearLayout>
    </TabHost>

</FrameLayout>

[/code]

satir_gorunum.xml

[code]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/file_icon"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:src="@drawable/abc_ab_bottom_transparent_dark_holo" />

    <TextView
        android:id="@+id/file_name"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:text="File Name"
        android:textSize="15dp" />

</LinearLayout>

[/code]

files.java

[code]

package com.example.arayuz;

public class files {
    private String isim ;
    private String tur;
    
    public files(String isim,String tur){
        this.isim = isim ;
        this.tur = tur;
    }

    public String getIsim() {
        return isim;
    }

    public void setIsim(String isim) {
        this.isim = isim;
    }

    public String getTur() {
        return tur;
    }

    public void setTur(String tur) {
        this.tur = tur;
    }

}

[/code]

ozelAdapter.java

[code]

package com.example.arayuz;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ozelAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private List<files> mFileList;
    
    public ozelAdapter (Activity activity, List<files> files){
        mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mFileList = files;
    }

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

    @Override
    public Object getItem(int position) {
        
        return null;
    }

    @Override
    public long getItemId(int position) {
        
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View SatirView;
        SatirView = mInflater.inflate(R.layout.satir_gorunum, null);
        TextView textView = (TextView) SatirView.findViewById(R.id.file_name);
        ImageView imageView= (ImageView) SatirView.findViewById(R.id.file_icon);
        
        files file = mFileList.get(position);
        textView.setText(file.getIsim());
        
        imageView.setImageResource(R.drawable.folderopened_yellow);
        
        return SatirView;
    }

}

[/code]

activity_sayfa1.xml

[code]

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.arayuz.Sayfa1"
    tools:ignore="MergeRootFrame" >

    <ListView
        android:id="@+id/liste"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</RelativeLayout>

[/code]

Sayfa1.java

[code]

package com.example.arayuz;

import java.util.ArrayList;
import java.util.List;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.os.Build;

public class Sayfa1 extends ActionBarActivity {
    final List<files> fileList = new ArrayList<files>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sayfa1);
        final ListView listemiz = (ListView) findViewById(R.id.liste);
        fileList.add(new files("Müzikler","ses"));
        fileList.add(new files("Resimler","görüntü"));
        fileList.add(new files("Ders Notları","döküman"));
        fileList.add(new files("Döküman","döküman"));
        fileList.add(new files("Projeler","belge"));
        fileList.add(new files("Programlar","exe"));
        ozelAdapter adaptorumuz=new ozelAdapter(this, fileList);
        listemiz.setAdapter(adaptorumuz);   
    }

}

[/code]

9 Görüntülenme

0 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.