Tried to replace bicycle brake housing. Broken cable? I was attempting to replace my stock front v brake to a better aftermarket v brake everything went ok until I tried to test it and the brake cable end, the one that connects to the brake lever, will not stay in place.



As you can see, the cable gets clamped at the brake lever entrance. On my bicycle the clamp or  ferrule will not stay in place. In other words, the cable does not tighten because it will not clamp into the brake lever, it slides.

My question is.. Can this be fixed? Perhaps I can glue it in somehow? Perhaps there is something that gets clamped in a different way?

Apologies for the vague explanation.
There are two types of brake anchor (one is plum-shaped, the other is barrel-shaped or cylindrical). If you have the wrong one at the brake end, it won't fit properly and will slide around.
To solve this, some brake cable vendors sell their cables with both types of end anchors attached. You just use the end that you need and cut off (with a proper brake line cutter, not a pair of pliers) the end you don't need:

Be sure to put a ferrule on the cut end of the cable because it will unravel. DIY options include shrink wrap, a cork, an electrical crimp connector, tape (not personally recommended), string, wire, hot glue, etc.