MainActivity にクラスを作成したい:
MyCard customCard1 = new MyCard(cardTitle.getText().toString(),
cardbuttonon.getText().toString(),
cardbuttonon.getText().toString(),
cardbuttonon.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String[] url={"url"};
new onoff(MainActivity.this).execute(url);
}});
mCardView.addCard(customCard1);
mCardView.refresh();
しかし、コンストラクタ MyCard(String,String,String,Object undefined は.
MyCardで彼を定義するにはどうすればよいですか:
package de.heron.cloudbox;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.fima.cardsui.objects.Card;
public class MyCard extends Card {
public MyCard(String title, String desc, String string, Object setOnClickListener){
super(title, desc);
}
@Override
public View getCardContent(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.card_ex, null);
((TextView) view.findViewById(R.id.title)).setText(title);
((TextView) view.findViewById(R.id.description)).setText(desc);
return view;
}
}
誰かが私の問題で私を助けることができますか?
なぜ私は2つのonclicklistenersでそれを作ることができますか:
MyCardXml customCard1 = new MyCardXml(cardTitle.getText().toString(),cardbuttonon = (Button) findViewById(R.id.cardbuttonon),cardbuttonoff = (Button) findViewById(R.id.cardbuttonoff),
cardbuttonon.getText().toString(),cardbuttonoff.getText().toString(),
cardbuttonon.getText().toString(),cardbuttonoff.getText().toString(),
cardbuttonon.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String[] url={"http://everhome.de/api/applive/", "8ef43502ad3dc04f87b4a48b993878c0","/" + KEY_ID,"/" + KEY_COST};
new onoff(MainActivity.this).execute(url);
}}
),cardbuttonoff.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String[] url={"http://everhome.de/api/applive/", "8ef43502ad3dc04f87b4a48b993878c0","/" + KEY_ID,"/" + KEY_COST};
new onoff(MainActivity.this).execute(url);
}}
));
mCardView.addCard(customCard1);
mCardView.refresh();