کد کامل جاوای این فایل :
package com.mws.dmp.irangardi;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.app.*;
import android.content.*;
import android.widget.*;
import android.view.*;
import android.widget.AdapterView.*;
import android.graphics.*;
public class subject extends Activity {
public ListView lv;
public int Subjects_total_number;
public String[] Subjects;
@Override
protected void onCreate(Bundle savedInstanceState)
{
//Remove notification bar
getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowM anager.LayoutParams.FLAG_FULLSCREEN );
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE) ;
super.onCreate(savedInstanceState);
setContentView(R.layout.subject);
// change subject
// Bundle extras = getIntent().getExtras();
// String myVariable_2 = extras.getString("subject_key");
//
final Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Koodak.ttf");
TextView txt = (TextView) findViewById(R.id.subject_textView);
txt.setTypeface(font);
String city;
String msource;
int img;
String[] Subjects1 = new String[716];
String[] Subjects2 = new String[716];
Integer[] imageId = new Integer[716];
for (int x = 1; x < 716 + 1; x = x + 1)
{
String this_subjectcity = "subject_city_" + String.valueOf(x);
int resIDcity = getResources().getIdentifier(this_subjectcity, "string", getPackageName());
city = getResources().getString(resIDcity);
String this_subject1 = "subject_" + String.valueOf(x);
int resID1 = getResources().getIdentifier(this_subject1, "string", getPackageName());
msource = getResources().getString(resID1);
String this_imageId = "imgm" + String.valueOf(x);
img = getResources().getIdentifier(this_imageId, "drawable", getPackageName());
if (city.equals("تهران"))
{
Subjects1[x-1] = msource;
Subjects2[x-1] = city;
imageId[x-1] = img;
}
else
{
Subjects1[x-1] = "";
Subjects2[x-1] = "";
imageId[x-1] = 0;
}
}
CustomList adapter = new CustomList(subject.this, Subjects1, Subjects2, imageId);
ListView list=(ListView)findViewById(R.id.list_view1);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Intent i = new Intent(getApplicationContext(), source.class);
String Subject_number = String.valueOf(position+1);
i.putExtra("subject_number", Subject_number);
startActivity(i);
}
});
}
}
و همینطور کد مربوط به فایل CustomList.java
package com.mws.dmp.irangardi;
import android.app.Activity;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.content.*;
import android.view.animation.*;
public class CustomList extends ArrayAdapter<String>{
//Typeface معرفی کلاس
private Typeface tf;
private final Activity context;
//معرفی نام و تصاویر از اکتیوتی
private final String[] subject_name1;
private final String[] subject_name2;
private final Integer[] imageId;
public CustomList(Activity context,String[] subject_name1,String[] subject_name2,Integer[] imageId) {
super(context, R.layout.list_file, subject_name1);
this.context = context;
this.subject_name1 = subject_name1;
this.subject_name2 = subject_name2;
this.imageId = imageId;
//فرواخوانی فونت از پوشه فونت
}
// private AssetManager getAssets()
// {
// // TODO: Implement this method
// return null;
// }
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.list_file, null, true);
TextView txtTitle1 = (TextView) rowView.findViewById(R.id.listfileTextView_text);
TextView txtTitle2 = (TextView) rowView.findViewById(R.id.listfileTextViewCITY);
//افزودن فونت به تکست ویو
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_right2);
rowView.startAnimation(animation);
ImageView imageView = (ImageView) rowView.findViewById(R.id.listfileImageView1);
txtTitle1.setText(subject_name1[position]);
txtTitle2.setText(subject_name2[position]);
txtTitle1.setTypeface(this.tf = Typeface.createFromAsset(context.getAssets(),"font s/Koodak.ttf"));
imageView.setImageResource(imageId[position]);
return rowView;
}}
اگه تغییراتی تو این دو فایل بابت عدم نمایش ردیفهای لیست ویو لازم هست ممنون میشم بگید