Bazı çalışma için benim android projemde basit bir SQLite yapmaya çalışıyorum. Buna, MyDBHandler'daki MyDBHandler() ile (this,null, null,null 1)
satırı uygulanamaz. Bunun bir olağan aktivite yerine bir parça olması nedeniyle bunu hissediyorum. Herhangi bir fikir?SQLite bir parça üzerinde
package com.test.test.sql;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
/**
* A simple {@link Fragment} subclass.
*/
public class MemoFragment extends Fragment {
EditText Input;
TextView LyricText;
MyDBHandler dbHandler;
Button addButtonClicked;
Button deleteButtonClicked;
public MemoFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_memo, container, false);
Input = (EditText) getView().findViewById(R.id.Input);
LyricText = (TextView) getView().findViewById (R.id.LyricText);
dbHandler = new MyDBHandler(this, null, null, 1);
printDatabase();
}
//add lyric to database
public void addButtonClicked(View view){
Lyrics lyrics = new Lyrics(Input.getText().toString());
dbHandler.addLyric(lyrics);
printDatabase();
}
//delete items
public void deleteButtonClicked(View view){
String inputText = Input.getText().toString());
dbHandler.deleteLyrics(inputText);
printDatabase();
}
public void printDatabase(){
String dbString = dbHandler.databasetoString();
LyricText.setText(dbString);
Input.setText("");
}
}
()' yöntem tanımlanmıştır? –
@BobMalooga MyDBHandler'de tanımlanmıştır. AddLyrics() 'yerine' addLyric() 'olması gereken bu hatayı düzelttim. Asıl konu olan 'findViewById' parçasının – DinoArmadillo
parçasında çalıştığı görünmüyor. Hatanız' findViewById() ile ilgisi yok . Fragmanlar içinde mükemmel çalışır. –