Kişisel Sayfaları
İlgi Alanları
İş Tecrubesi
Eğitim Geçmişi
Sertifikalar & Başarılar
Kullanıcıya ait test sonucu bulunmamaktadır.
Dil Becerileri
Son Forum Aktiviteleri
8sdCard içinde klasör silme
Merhabalar,
Şu kod ile sdCard içindeki uzantısını verdiğim video ya da herhangi bir txt dosyasını siliyorum , BEN SDCARD İÇİNDEKİ 1.MP4 DEĞİLDE KLASÖRÜ SİLMEK İSTİYORUM Ama denedim olmadı
File folder = Environment.getExternalStorageDirectory();
String fileName = folder.getPath() + "/ekrem/videolar/1.mp4";
File myFile = new File(fileName);
if (myFile.exists())
myFile.delete();
***********************************************************************************************************************************************************************************
şu şekilde kullandım ama klasörü silmedi
Button sil = (Button) findViewById(R.id.button3);
sil.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Sil", Toast.LENGTH_SHORT).show();
File dir = new File(Environment.getExternalStorageDirectory()+"/ekrem");
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
new File(dir, children[i]).delete();
}
}
}
});
Sdcard içindeki Resimleri slaydırda gösterme
Merhaba
Aşağıdaki kodları kullanarak slider yaptım , burada URL ve DRAWABLE'dan resimleri alıyor ama ben sdcard içinden almak istiyorum nasıl yapabilirim ?
Teşekkürler. . .
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDemoSlider = (SliderLayout)findViewById(R.id.slider);
HashMap<String,String> url_maps = new HashMap<String, String>();
url_maps.put("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg");
url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
url_maps.put("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg");
HashMap<String,Integer> file_maps = new HashMap<String, Integer>();
file_maps.put("Hannibal",R.drawable.hannibal);
file_maps.put("Big Bang Theory",R.drawable.bigbang);
file_maps.put("House of Cards",R.drawable.house);
file_maps.put("Game of Thrones", R.drawable.game_of_thrones);
for(String name : file_maps.keySet()){
TextSliderView textSliderView = new TextSliderView(this);
// initialize a SliderLayout
textSliderView
.description(name)
.image(file_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);
//add your extra information
textSliderView.getBundle()
.putString("extra",name);
mDemoSlider.addSlider(textSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Accordion);
mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
mDemoSlider.setCustomAnimation(new DescriptionAnimation());
mDemoSlider.setDuration(4000);
ListView l = (ListView)findViewById(R.id.transformers);
l.setAdapter(new TransformerAdapter(this));
l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mDemoSlider.setPresetTransformer(((TextView) view).getText().toString());
Toast.makeText(MainActivity.this, ((TextView) view).getText().toString(), Toast.LENGTH_SHORT).show();
}
});
}
Rss 'den resimleri çekme
Title ve Link'e gidebiliyorum fakat Image'leri alamıyorum.
İmage'leride almak istiyorum ama alamıyorum nasıl yapabilirim teşekkürler.
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class Haber extends Activity {
ArrayList<String> xmlList=new ArrayList<String>();
ArrayList<String> xmlLink=new ArrayList<String>();
ArrayList <String> xmlImage=new ArrayList <String>();
public class arkaPlanIsleri extends AsyncTask<Void, Void, Void> {
private ProgressDialog dialog = new ProgressDialog(Haber.this);
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
ListView listView1 = (ListView)findViewById(R.id.list);
MyCustomAdapter adapter = new MyCustomAdapter(Haber.this, R.layout.list, xmlList);
listView1.setAdapter(adapter);
dialog.dismiss();
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
dialog.setMessage("Yükleniyor...");
dialog.show();
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
xmlList=getListFromXml("http://rss.hurriyet.com.tr/rss.aspx?sectionId=2");
xmlLink=getLinkFromXml("http://rss.hurriyet.com.tr/rss.aspx?sectionId=2");
xmlImage=getImageFromXml("http://rss.hurriyet.com.tr/rss.aspx?sectionId=2");
return null;
}
}
public class MyCustomAdapter extends ArrayAdapter<String> {
public MyCustomAdapter(Context context, int textViewResourceId,
ArrayList<String> xmlList) {
super(context, textViewResourceId, xmlList);
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
View row = convertView;
if(row==null){
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.list, parent, false);
}
TextView label=(TextView)row.findViewById(R.id.text1);
label.setText(xmlList.get(position));
ImageView image =(ImageView)row.findViewById(R.id.img);
image.setImageResource(R.drawable.bg_app);
return row;
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
new arkaPlanIsleri().execute();
ListView listView1 = (ListView)findViewById(R.id.list);
listView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Uri link = Uri.parse(xmlLink.get(position));
final Intent openBrowser = new Intent(Intent.ACTION_VIEW,link);
startActivity(openBrowser);
}
});
}
// TODO Auto-generated method stub
//super.onListItemClick(l, v, position, id);
public ArrayList<String> getListFromXml(String strng) {
ArrayList<String> list=new ArrayList<String>();
try {
URL url=new URL(strng);
DocumentBuilderFactory dFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder=dFactory.newDocumentBuilder();
Document document=dBuilder.parse(new InputSource(url.openStream()));
document.getDocumentElement().normalize();
NodeList nodeListCountry=document.getElementsByTagName("haber");
for (int i = 0; i < nodeListCountry.getLength(); i++) {
Node node=nodeListCountry.item(i);
Element elementMain=(Element) node;
NodeList nodeListText=elementMain.getElementsByTagName("baslik");
Element elementText=(Element) nodeListText.item(0);
list.add(elementText.getChildNodes().item(0).getNodeValue());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
public ArrayList<String> getLinkFromXml(String strng) {
ArrayList<String> list=new ArrayList<String>();
try {
URL url=new URL(strng);
DocumentBuilderFactory dFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder=dFactory.newDocumentBuilder();
Document document=dBuilder.parse(new InputSource(url.openStream()));
document.getDocumentElement().normalize();
NodeList nodeListCountry=document.getElementsByTagName("link");
for (int i = 0; i < nodeListCountry.getLength(); i++) {
Node node=nodeListCountry.item(i);
Element elementMain=(Element) node;
NodeList nodeListText=elementMain.getElementsByTagName("link");
Element elementText=(Element) nodeListText.item(0);
list.add(elementText.getChildNodes().item(0).getNodeValue());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
public ArrayList<String> getImageFromXml(String strng) {
ArrayList<String> list=new ArrayList<String>();
try {
URL url=new URL(strng);
DocumentBuilderFactory dFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder=dFactory.newDocumentBuilder();
Document document=dBuilder.parse(new InputSource(url.openStream()));
document.getDocumentElement().normalize();
NodeList nodeListCountry=document.getElementsByTagName("description");
for (int i = 0; i < nodeListCountry.getLength(); i++) {
Node node=nodeListCountry.item(i);
Element elementMain=(Element) node;
NodeList nodeListText=elementMain.getElementsByTagName("description");
Element elementText=(Element) nodeListText.item(0);
list.add(elementText.getChildNodes().item(0).getNodeValue());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return list;
}}
media player url
https://gelecegiyazanlar.turkcell.com.tr/konu/android/egitim/android-301/asynctask
incelersen problemini çözersin umarım kolay gelsin.
Android ses ekleme hatasi
Projeni başka bir projeden kopyalayıp yapıştırıyorsan R dosyaları çakışıyordur , manifest dosyanda projenin ismini kontrol etmen sorununu çözecektir.
Android Studio kütüphane ekleme
"Gradle Scripts" > altında >"build.gradle(Module.app)" ; build.gradle(Module.app) içerisinde şu şekilde bir yapı var oraya gerekli kütüphaneyi ekleyıp sorununuzu çözebilirsiniz
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.2@aar'
}