Is defining the SwipeInterceptorView programatically good practice, or should I add it to my XML file?
It is best practice to define the View
in XML
, since this provides a reusable file (so you can using it elsewhere in your app, or again in another app).
That said, it is not bad practice to instantiate it programmatically - it just reduces the reusability factor.
how can I fix this XML file?
I am currently unsure as to why this is not working. I will be looking into it in more detail ASAP. In the mean time, one sure thing would be to download the entire project, import it into your workspace, and add it as a library project, rather than a jar.
Also, i know how to add the onClickListener to an ImageView, but could anyone tell me how I should add the listener to a TextView also?
You can add the click listener exactly the same way:
mTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//your code
}
});
If you want to make full use of the droidQuery
library, you can optionally use one of these methods instead:
click
$.with(mTextView).click(new Function() {
@Override
public void invoke($ droidQuery, Object... params) {
//your code
}
});
on
$.with(mTextView).on("click", new Function() {
@Override
public void invoke($ droidQuery, Object... params) {
//your code
}
});
one (only handles click once)
$.with(mTextView).one("click", new Function() {
@Override
public void invoke($ droidQuery, Object... params) {
//your code
}
});
bind
Object data = new Object();//could be anything
$.with(mTextView).on("click", data, new Function() {
@Override
public void invoke($ droidQuery, Object... params) {//data will be passed as a param
//your code
}
});